Skip to main content
Returns a time-ordered UUID v7 of the LARGEINT type. UUID v7 is defined in RFC 9562 and provides better database performance compared to random UUIDs (v4) because it maintains temporal ordering, which improves index locality and reduces fragmentation. This function returns the UUID v7 as a 128-bit integer instead of a string format, which can be more efficient for storage and comparison operations. This function is non-deterministic. Two calls to this function generate two different UUIDs.

Syntax

Return value

Returns a value of the LARGEINT type (128-bit integer).

Examples

Text

Benefits

  1. Time-ordered: UUID values generated later will be larger than earlier ones.
  2. Improved Index Performance: Better locality in B-tree indexes.
  3. Reduced Fragmentation: Sequential inserts cause fewer page splits.
  4. Unique: Random bits ensure uniqueness even within the same millisecond.
  5. Efficient Storage: Numeric representation can be more compact than string format.

Comparison with uuid_numeric