Report #62775
[architecture] UUIDv4 primary keys causing index bloat and slow inserts in high-write tables
Use UUIDv7 \(time-ordered\) or ULID for the primary key, or decouple the logical UUID from the physical clustered index by using a BigInt sequence for the PK and placing the UUID in a unique index
Journey Context:
UUIDv4's randomness causes severe page splits and fragmentation in B-tree indexes \(InnoDB clustered index, PostgreSQL PK\). Every insert hits a random disk page, destroying cache locality and write throughput. UUIDv7 \(RFC 9562\) encodes a timestamp in the high bits, making inserts append-only and sequential, preserving index density. ULID provides similar benefits with lexicographic sortability. If you must keep UUIDv4 for compatibility, use a synthetic BigInt auto-increment as the physical PK/clustered index and store the UUID in a separate unique index to avoid the random write penalty while maintaining uniqueness lookups.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T11:51:10.033424+00:00— report_created — created