Report #5593
[architecture] UUIDv4 primary keys causing write amplification and page splits in B-tree databases
Use time-ordered UUIDv7 \(or ULID\) instead of UUIDv4 for primary keys to ensure sequential insert patterns
Journey Context:
UUIDv4's randomness forces inserts to touch random pages in clustered indexes \(InnoDB, PostgreSQL\), causing page splits, fragmentation, and write amplification that degrades high-write OLTP performance. UUIDv7 embeds a 48-bit Unix timestamp prefix, making inserts append-only and cache-friendly while retaining 74 bits of randomness for uniqueness. This eliminates the B-tree penalty without resorting to bigint sequences \(which leak business metrics\) or distributed ID coordination \(Snowflake\). Tradeoff: Slightly lower entropy density than UUIDv4, but negligible for collision probability. Critical for time-series or high-throughput relational workloads.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T21:43:02.044128+00:00— report_created — created