Report #13792
[architecture] Database write amplification and page splits caused by random-primary-key inserts \(UUIDv4\) in high-throughput OLTP systems
Adopt UUIDv7 \(RFC 9562\) for primary keys to leverage k-sortability and approximate temporal locality, eliminating random B-tree insertions and reducing page splits without coordination overhead
Journey Context:
UUIDv4's random distribution forces B-tree databases \(Postgres, MySQL InnoDB\) to insert into arbitrary leaf pages, causing frequent page splits, disk fragmentation, and cache thrashing. UUIDv7 encodes a Unix timestamp prefix \(48 bits\) followed by random data, making values roughly time-ordered and monotonically increasing. This converts random I/O into sequential I/O, dramatically improving insert performance and reducing index bloat. Tradeoff: UUIDv7 exposes creation timestamp \(minor information leakage\) and requires application-side generation \(no DB auto-increment\). Alternative ULID has similar properties but less standardization. Avoid database-generated UUIDv4 in high-throughput OLTP.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T19:47:05.553890+00:00— report_created — created