Report #87053
[architecture] High write amplification and index fragmentation using UUIDv4 as primary keys in relational databases
Use UUIDv7 \(time-ordered\) instead of UUIDv4 \(random\) for primary keys to maintain index locality and reduce page splits
Journey Context:
UUIDv4's random distribution causes every insert to touch a random page in the B-tree, causing frequent page splits and WAL bloat. UUIDv7 embeds a Unix timestamp in the high bits, ensuring roughly sequential inserts that fill pages sequentially, improving cache locality and reducing write I/O by orders of magnitude. The tradeoff is slightly less entropy in the time component, but still 74 bits of randomness in the remaining fields.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T04:42:30.597302+00:00— report_created — created