019cd626-afae-77c0-8afd-42e2b54e641367UUID v7 is a time-ordered UUID suitable for database primary keys.
UUID v7 is a time-ordered UUID format that encodes a Unix timestamp in the first 48 bits, followed by random bits. This makes the UUIDs sortable by creation time while maintaining uniqueness.
UUID v7 addresses the main drawbacks of UUID v4 (not sortable) and UUID v1 (privacy concerns with MAC address). It's becoming the recommended format for database primary keys in modern applications.
Database Keys
Use as primary keys with natural time ordering
Logging
Create time-ordered log entry identifiers
Distributed Systems
Generate sortable IDs across multiple servers
Event Streams
Create ordered event IDs for streaming systems
What is UUID v7?
UUID v7 is a time-ordered UUID format defined in RFC draft. It encodes a Unix timestamp in the first 48 bits, followed by random data. Unlike UUID v4 (random), UUID v7 values sort in chronological order.
Why use time-ordered UUIDs?
Time-ordered UUIDs combine the benefits of auto-increment IDs (natural sort order, B-tree friendly) with UUIDs (no coordination needed, no disclosure of business metrics). They're ideal for distributed systems.
How is UUID v7 different from UUID v4?
UUID v4 is completely random - useful for security but not sortable. UUID v7 includes a timestamp component, making it sortable and suitable for database primary keys where insertion order matters.
Can I use UUID v7 as database primary keys?
Yes! UUID v7 is specifically designed for this use case. Unlike UUID v4, the time-ordered nature means new rows insert at the end of the index, maintaining good B-tree performance. It's a popular choice for distributed databases.
What about UUID v1?
UUID v1 also contains a timestamp but uses the MAC address of the generating machine, which raises privacy concerns. UUID v7 uses random bits instead, providing better privacy while maintaining sortability.
Privacy First
All UUID generation happens in your browser. Your data never leaves your device.