UUID v4 inserts land at random B-tree positions, causing page splits and cache misses at scale. UUID v7’s timestamp prefix clusters inserts at the rightmost leaf — near auto-increment performance. PostgreSQL 18 ships uuidv7() as a built-in. See UUID in Databases for benchmarks.
Storage: use PostgreSQL uuid type (16 bytes) or MySQL BINARY(16) with UUID_TO_BIN(uuid,1). Never VARCHAR(36).
Read more: UUID vs Auto-Increment · MySQL UUID Storage · Zero-Downtime Migration
Generate a UUID v7 · UUID Decoder · UUID Converter
Frequently asked questions
Do videos on UUID database performance actually explain B-tree fragmentation?
Good UUID database performance videos explain that UUID v4 causes B-tree page splits because each new value inserts at a random position, fragmenting the index. UUID v7 solves this — its timestamp prefix means consecutive inserts cluster at the rightmost leaf, the same behaviour as auto-increment. See UUID Database Primary Keys video walkthrough and the full UUID in Databases guide.
Do UUIDs hurt database index performance?
UUID v4 does — its randomness causes every insert to land at a different leaf page, leading to page splits and poor cache locality. UUID v7 embeds a millisecond timestamp so consecutive inserts cluster together, behaving like an auto-increment integer for B-tree purposes.
Does PostgreSQL 18 support UUID v7 natively?
Yes. PostgreSQL 18 ships a built-in uuidv7() function that generates RFC 9562-compliant UUID v7 values directly in SQL — no extensions or application-level generation required. The values store in the existing uuid column type unchanged.