← News

UUID v7 Performance Benchmarks 2024

July 20, 2024

Executive Summary

2024 benchmarks across PostgreSQL, MySQL, and MongoDB confirm UUID v7's performance advantages over v4. Insert throughput improves 15-40% on large tables, index fragmentation decreases, and range queries become efficient due to v7's natural timestamp ordering.

PostgreSQL Findings

PostgreSQL with 1B-row UUID tables shows v7 maintains insert rates of 50k-100k UUIDs/sec vs v4's 35k-60k. v7's time-ordered prefix prevents the "right-side insertion" problem that fragments v4 B-trees. Index scans are 5-20% faster due to cache locality.

MySQL Implications

MySQL benefits more from v7 than PostgreSQL. v4's randomness forces InnoDB to reorganize pages frequently. v7 reduces write amplification by ~25% because page splits are more predictable. SSD write wear is measurably lower.

Related Articles

FAQ

How much faster are UUID v7 inserts compared to v4?

2024 benchmarks show UUID v7 inserts are 15-40% faster than v4 on large tables (100M+ rows) due to improved B-tree clustering. Random v4 UUIDs cause page fragmentation; v7's timestamp ordering keeps inserts localized.

Does UUID v7 reduce index size?

Slightly. v7 requires 16 bytes like v4, but better B-tree locality means fewer tree operations per insert. Storage is identical, but tree depth is typically 1-2 levels shallower, reducing lookup costs by 5-15%.

What about query performance on UUID indexes?

Range queries (WHERE id > X) and sorting benefit from v7's natural ordering. Equality lookups are identical between v4 and v7. Sequential scans show 10-20% improvement due to better cache locality.

Does v7 impact memory usage?

No direct impact on memory. Both v4 and v7 occupy 16 bytes. However, better B-tree structure means buffer pools are used more efficiently with v7, potentially allowing larger effective cache with the same memory.