UUIDv7 Comes to PostgreSQL 18

May 25, 2025

UUIDv7 Comes to PostgreSQL 18. A blog post from Nile that discusses the new UUID version that will come with the next PostgreSQL release.

Essentially, in regard to the use of UUIDs in databases, there are 3 common concerns: sorting, index locality and size. The new version solves the sorting and index locality by using Unix Epoch timestamp as the most significant 48 bits, keeping the other 74 bits for random values.

By calling uuidv7(), a new UUIDv7 can be generated with the timestamp set to current time. An optional interval can be passed to generate a value for a different time

select uuidv7(INTERVAL '1 day');

#postgresql #uuid #database