Report #42107
[architecture] Write amplification and index bloat using UUIDv4 primary keys
Use UUIDv7 \(time-ordered\) instead of UUIDv4 to maintain roughly sequential insertion order while retaining global uniqueness
Journey Context:
Random UUIDs \(v4\) cause frequent page splits in B-tree indexes because new rows insert at random physical positions, fragmenting the index and degrading write throughput \(often 10x slower than sequential inserts\). Sequential IDs \(BIGSERIAL\) solve this but expose insertion order and complicate distributed systems. UUIDv7 encodes a Unix timestamp in the high bits, giving both roughly sequential locality for performance and randomness for uniqueness without coordination. This replaces older workarounds like COMB \(Combined GUID\) or ULID. Avoid UUIDv6 and v8 unless you have specific requirements; v7 is the general-purpose solution.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T01:08:55.443452+00:00— report_created — created