Skip to content

Instantly share code, notes, and snippets.

View stephanGarland's full-sized avatar

Stephan Garland stephanGarland

View GitHub Profile
@stephanGarland
stephanGarland / pg_bench_jsonb_indices.md
Last active March 29, 2024 17:10
Comparing Postgres access speeds on JSONB with various indices

Environment

System

  • OS: Debian 12 VM on Proxmox VE 8
  • CPUs: 8x Xeon E5-2620 v2
  • RAM: 8 GiB DDR3
  • HDD: Samsung PM863 NVMe in Ceph over Mellanox Infiniband 56 Gbps IPoIB
    • Virtualized via scsi-virtio-single, aio=native, io_threads=enabled
  • FS: ext4 (rw,noatime)
@stephanGarland
stephanGarland / uuid_arc4random_vs_random.md
Created July 14, 2024 15:01
Demonstrating arc4random vs. ul_random_get_bytes performance difference

Results

All programs compiled with -O3, using clang v15.0.0 on MacOS, and gcc 10.2.1 on Linux. Mac was an M1 Air base model (8 GiB RAM), with low power mode disabled. Linux server was a Debian 11 VM with a Xeon E5-2650 v2 @ 2.60GHz, and 64 GiB of PC3-12800R RAM.

Linux

❯ ./uuid_runner.sh
@stephanGarland
stephanGarland / sqlalchemy_enum.py
Created December 20, 2024 18:39
Demonstration of lookup tables with SQLAlchemy that automatically update with new entries
import itertools
import uuid
from functools import lru_cache
from typing import Dict, List, Optional, Union
from sqlalchemy import (Column, DateTime, ForeignKey, Integer, String,
create_engine)
from sqlalchemy.dialects import mysql
from sqlalchemy.orm import (Session, declarative_base, relationship,
sessionmaker)
@stephanGarland
stephanGarland / mysql_57_varchar_enum_json.md
Created February 7, 2025 17:37
Comparing VARCHAR, ENUM, and JSON indexed performance in MySQL 5.7

Environment

System

  • Macbook Pro M3
  • RAM: 36 GiB
  • SSD: 500 GB

MySQL

@stephanGarland
stephanGarland / macos_modify_mysql_configs.py
Created May 8, 2025 13:58
Modify MySQL config files on MacOS as installed by Homebrew to alllow simultaneous 5.7 and 8.0 installations
import configparser
import plistlib
import shutil
import subprocess
from enum import Enum
from pathlib import Path
from string import Template
from typing import NamedTuple, Optional
EXEC_START_TMPL = Template("/opt/homebrew/opt/mysql@${mysql_ver}/bin/mysqld_safe")
@stephanGarland
stephanGarland / macos_local_mysql_multiple_versions.md
Created May 8, 2025 14:20
Run local MySQL 5.7 and 8 simultaneously on MacOS via Homebrew

Prerequisites

Mac

This has been tested only on ARM (Apple Silicon) Macs. YMMV on x86. I don't see why it wouldn't work, but you may need to change some directory paths.

MySQL

You'll need to have MySQL 5.7 and 8 installed. The former is somewhat tricky, because the