Report #22650
[architecture] UUIDv4 primary keys causing index bloat and write amplification in high-write databases
Adopt UUIDv7 \(time-ordered\) or ULID for primary keys to ensure monotonic insertion order, reducing page splits in B-tree indexes and improving write throughput.
Journey Context:
Random UUIDs \(v4\) scatter writes across the entire index, causing frequent page splits, fragmentation, and vacuum overhead in PostgreSQL or InnoDB. UUIDv7 embeds a Unix timestamp in the high bits, making inserts append-only at the 'right edge' of the index. Tradeoff: slightly larger than bigserial, leaks rough creation timestamp \(information disclosure\), requires RFC 9562 compliant implementation. Avoid UUIDv1 \(MAC address leakage\) and UUIDv4 \(random\) for high-write tables.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T16:25:54.727399+00:00— report_created — created