compare ยท developer
UUID v4 vs UUID v7 Comparison
Compare UUID v4 vs UUID v7: random vs time-ordered sorting, database B-tree index fragmentation, and RFC 9562 specs. Free UUID generator.
Updated 2026-09-07
Use Random UUID Generator
Side-by-side comparison
| Factor | UUID_V4 | UUID_V7 |
|---|---|---|
| ordering_sortability | Pure random 122 bits; completely unordered | Chronologically sortable; embedded millisecond timestamp |
| database_indexing | Causes severe B-tree page fragmentation and cache evictions | Sequential inserts maintain B-tree locality and high performance |
| time_extraction | Impossible to extract timestamp from ID | 48-bit Unix timestamp extractable directly from the ID |
| entropy_collisions | 122 bits of randomness; collisions virtually impossible | 74 bits of randomness + sub-millisecond counter; collision-safe |
| standard_rfc | RFC 4122 (published 2005) | RFC 9562 (officially standardized in 2024) |
| legacy_library_support | Built into every language and framework natively | Supported in modern releases of PostgreSQL 17+, Go, Node, Python |
When to use which
- Primary keys in relational databases (PostgreSQL, MySQL): UUID_V7
- Opaque random security tokens where time must remain hidden: UUID_V4
- Time-series logging and event tracking: UUID_V7
- Legacy platforms without RFC 9562 support: UUID_V4
FAQ
- Why does UUID v4 degrade database performance at scale?
- UUID v4 is completely pseudorandom. When used as a primary key in B-tree indexes (like in PostgreSQL or MySQL InnoDB), new records are inserted at random memory pages. This causes frequent page splits, heavy disk I/O, and buffer pool churn.
- How does UUID v7 solve database index fragmentation?
- UUID v7 begins with a 48-bit Unix timestamp in milliseconds. Because IDs are generated in chronological order, new database records append sequentially to the rightmost leaf of the B-tree index, mimicking the high performance of auto-incrementing integers while retaining UUID uniqueness.
- Is UUID v7 officially standardized?
- Yes. In May 2024, the IETF published RFC 9562, officially standardizing UUID versions 6, 7, and 8 as modern successors to the legacy RFC 4122 specification.
- Can I extract the creation timestamp from a UUID v7?
- Yes. The first 48 bits encode the milliseconds elapsed since the Unix epoch (January 1, 1970). You can extract the exact creation time without querying a separate created_at database column.