UUIDv7

UUIDv7 provides incredible database speeds

UUIDv7 provides incredible database speeds

Seventh version UUID (Universally Unique Identifier Version 7, UUID Version 7, UUIDv7) is a modified and standardized version ULID. Draft standard (hereinafter referred to as the standard) is awaiting final review by the editor. But there are already a large number of UUIDv7 implementations used in existing information systems. There is a lot of information available on the Internet on the keyword UUIDv7.

The development goals of UUIDv7 were to eliminate significant shortcomings of UUID and standardize (not present in ULID) – for the widespread use of UUIDv7 “by default” instead of other composite identifiers and auto-increment (integers) as surrogate keys in databases and as keys in distributed information systems ( as well as for other purposes specified in the standard).

The leftmost segment of the UUIDv7 contains a Unix epoch timestamp in milliseconds (timestamp), so that generated UUIDv7s tend to increase in time (this is the so-called monotonicity) and therefore are much faster in databases. In advanced implementations, there is a Fixed-Length Dedicated Counter between the timestamp and the pseudo-random segment, which ensures that the generated UUIDv7 increases while the timestamp remains unchanged within a millisecond interval.

The standard contains safety requirements:

  • to hide the date of creation of records, allows the time stamp to be shifted relative to the real date and time by any amount (but does not allow the time stamp to be filled with data that does not depend on the current time, in order to ensure monotonicity and protection from collisions)

  • prohibits UUIDv7 parsing unless absolutely necessary, including to extract and use a timestamp

  • requires implementation of protection against clock reversal

  • describes ways to protect against counter overflow

  • to protect against identifier brute-force attacks requires filling the rightmost segment of the UUIDv7 with pseudo-random data generated specifically for each UUIDv7

  • requires implementing protection against lack of access to the generator of truly random numbers, which are needed as “salt” for initializing pseudo-random data

The standard intentionally leaves some important issues to the discretion of implementation developers. Therefore, UUIDv7 implementations differ significantly from each other in UUIDv7 structure, time and entropy sources, algorithms, reliability, monotonicity, and performance.

The standard allows UUIDv7 to be used as the left segment of the key. In this case, the right segment of the key can be filled with any metadata and checksum.

No key parts can be placed to the left of the UUIDv7 timestamp, but if you need to space the UUIDv7 further out in the table, you can use the allowed timestamp offset.

The standard allows UUIDv7 to be used in conjunction with other identifiers. For example, a record might store a UUIDv7 generated by the database, and also, for integrity and feedback purposes, a key from the source system, which might also be a UUIDv7.

The standard contains priorities for the use of UUIDv7 and other versions of UUID. In most cases, the seventh version is recommended, and in rare cases when the monotonicity of the UUID is not important, the fourth version is recommended.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *