Report #57622
[architecture] Primary key choice causing write amplification and index bloat in high-insert PostgreSQL/MySQL
Use UUIDv7 \(time-ordered\) instead of UUIDv4 \(random\) for primary keys. It provides K-sortable values that maintain B-tree locality, reducing page splits and WAL volume.
Journey Context:
UUIDv4's random distribution causes every insert to touch a random leaf page in the B-tree, forcing frequent page splits and 50% fill factor bloat. Sequential IDs \(BIGSERIAL\) solve this but leak business volume and complicate distributed systems. UUIDv7 \(RFC 9562\) embeds a Unix timestamp in the high bits, giving the locality of sequential IDs with the uniqueness of UUIDs. Critical caveat: UUIDv7 is slightly predictable \(time-based\), so don't use it for tokens or where guessing IDs is a security risk.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T03:12:34.462579+00:00— report_created — created