ХабрПостыНовостиМегапосты?

What May Surprise You About UUIDv7

IDs are bearings of any DB
IDs are bearings of any DB


UUIDv7 was inspired by ULID. Like ULID, it is a 128-bit identifier, containing a timestamp on the left side and random data on the right side. In databases and distributed systems, a properly implemented UUIDv7 is always preferred over any other identifier type, including natural keys, autoincrement, UUIDv4, TypeID, ULID, KSUID, CUID, NanoID, and Snowflake ID.

There are notable distinctions of UUIDv7:

UUIDv7 and bigint demonstrate equivalent search and write performance confirmed by benchmarks. The rate of UUIDv7 generation is always sufficient and does not affect the performance of databases.

Although UUIDv7 is twice as long as a bigint, the difference in actual disk space used is much smaller. Besides, using UUID instead of bigint eliminates the need for intermediate tables and data layers.

UUIDv7, with the same performance, eliminates the following shortcomings of auto-increment:

You can use UUIDv7 in the same column where other versions of UUID (or ULID in binary format) are already used.

@SergeyProkhorenko
21.06.2025 21:00 UTC
Первоисточник