Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

UUIDv7 puts a Unix timestamp, measured in milliseconds, in its first 48 bits. As a result, UUIDv7 values are designed to sort by timestamp when compared as raw bytes—but that alone does not guarantee the exact order in which identifiers were generated. The timestamp is also visible in the identifier, so anyone who obtains one can decode its approximate encoded time.

How UUIDv7 encodes time

RFC 9562 §5.7 defines UUIDv7’s leading 48 bits as a big-endian unsigned count of Unix epoch milliseconds. The timestamp source excludes leap seconds. After it come the version field, a 12-bit rand_a field, the variant field, and a 62-bit rand_b field.

Those two fields outside the timestamp, version, and variant—74 bits in total—are random by default. Implementations can instead use some of the available bits for sub-millisecond precision or monotonicity mechanisms, while retaining random data. The format therefore defines where the timestamp goes, but does not prescribe one universal recipe for every bit after it.

What timestamp ordering does—and does not—mean

Because the timestamp occupies the most significant bits, UUIDv7 values with earlier encoded millisecond timestamps sort before values with later timestamps when compared as raw bytes. RFC 9562 §6.11 says UUIDv7 is designed to support this opaque bytewise sorting, without first parsing the identifier.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

That ordering is by encoded timestamp, not necessarily by exact generation time. Two UUIDs made in the same millisecond share the timestamp portion. If their remaining bits are random, their relative order is arbitrary; random bits support probabilistic uniqueness, not a record of which UUID was generated first.

For applications that need a more predictable sequence within a timestamp tick, RFC 9562 §6.2 describes options including a counter, monotonic random values, and using some available random bits for sub-millisecond clock precision. These techniques require implementation care: counter rollover must not break the ordering, and clock rollback can complicate time-based sequencing. The RFC recommends checking that a new UUID exceeds the previous one when monotonicity matters; applications requiring absolute monotonicity must prevent rollover from violating it.

What a UUIDv7 can reveal

The leading timestamp field can be decoded into a Unix-epoch millisecond value. A UUIDv7 therefore exposes approximate temporal information in a way that a random UUIDv4 ordinarily does not. This is a property of the format; it does not establish that the encoded time exactly matches a business event, nor does the field alone show what privacy consequences follow in a particular application. The clock source and implementation behavior affect what the value represents.

Why bytewise order matters for databases

RFC 9562 §6.11 says UUIDv6 and UUIDv7 are designed so systems that need sorting, such as database indexes, can sort them as opaque raw bytes. The RFC also notes that time-ordered monotonic UUIDs can improve index locality because nearby new values tend to land near one another in the index.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

This is a design rationale, not a universal performance guarantee. RFC 9562 gives no benchmark for a particular database, workload, or UUID library, so the specification does not establish a numerical speedup.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

UUIDv7 field summary

Field Size Purpose
Timestamp 48 bits Big-endian Unix epoch milliseconds; leap seconds are excluded from the timestamp source.
Version 4 bits Identifies the UUID as version 7.
rand_a 12 bits Random by default; may support optional monotonicity or sub-millisecond precision methods.
Variant 2 bits Identifies the UUID variant.
rand_b 62 bits Random by default; may support optional monotonicity methods.

Field sizes and behavior are specified in RFC 9562, especially §§5.7, 6.1, 6.2, and 6.11, published by the IETF in May 2024.

Quick Recap

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.