The Hidden Cost of UUID v4 in Databases
Traditional UUID v4 is completely random across all 128 bits. While this ensures zero collisions, inserting random UUIDs as primary keys in relational databases (PostgreSQL, MySQL, SQL Server) causes severe B-Tree index fragmentation:
- Every insert writes to a random memory page on disk.
- Page splits degrade write throughput by up to 75% on large tables.
Why UUID v7 is the Modern Standard
UUID v7 (RFC 9562) begins with a 48-bit Unix millisecond timestamp followed by random bits. This gives you:
- Monotonically increasing order: Inserts always append to the end of database B-Trees, preserving write speeds.
- Global uniqueness: Zero risk of collision across distributed server clusters.
Generate single or bulk batches with the UUID Generator Tool on Tools24Now.