Skip to content

generate_uuidv7()

Generate a version 7 UUID based on current time

Since 2.23.0

Generate a UUIDv7 object based on the current time.

The UUID contains a UNIX timestamp split into millisecond and sub-millisecond parts, followed by random bits.

You can use this function to generate a time-ordered series of UUIDs suitable for use in a time-partitioned column in TimescaleDB.

UUIDv7 structure with microsecond-precision timestamp
  • Generate a UUIDv7 object based on the current time

    SELECT generate_uuidv7();
    generate_uuidv7
    --------------------------------------
    019913ce-f124-7835-96c7-a2df691caa98
  • Insert a generated UUIDv7 object

    INSERT INTO alerts VALUES (generate_uuidv7(), 'high CPU');
ColumnTypeDescription
generate_uuidv7UUIDA UUIDv7 object based on the current time with random bits.