Daniel Vérité: Producing UUIDs Version 7 disguised as Version 4 (or 8)
postgresql.verite.pro·22h
Flag this post

Since RFC-9562 was published last year, there has been a growing interest in replacing random-only UUIDv4 keys by UUID-v7, which are made from a creation timestamp plus random numbers. As the sort order of UUID-v7 is inherently chronological, index access tends to be much more efficient than with UUID-v4.

Quoting the RFC:

UUID versions that are not time ordered, such as UUIDv4 (described in Section 5.4), have poor database-index locality. This means that new values created in succession are not close to each other in the index; thus, they require inserts to be performed at random locations. The resulting negative performance effects on the common structures used for this (B-tree and its variants) can be dramatic.

UUID-v7 solves …

Similar Posts

Loading similar posts...