- No extra column required to partition by time with sortability: you can sort UUIDv7 instances by their value. This is useful for ordering records by creation time without the need for a separate timestamp column.
- Indexing performance: UUIDv7s increase with time, so new rows are appended near the end of a B-tree. This results in fewer page splits, less fragmentation, faster inserts, and efficient time-range scans.
- Easy keyset pagination:
WHERE id > :cursorand natural sharding. - UUID: safe across services, replicas, and unique across distributed systems.
Samples
-
High-rate event logs for observability and metrics:
UUIDv7 gives you globally unique IDs for traceability and time windows such as “last hour”, without the need for a
separate
created_atcolumn. UUIDv7 creates less churn because inserts land at the end of the index, and you can filter by time using UUIDv7 objects.- Last hour:
- Keyset pagination:
- Last hour:
-
Workflow / durable execution runs:
Each run needs a stable ID for joins and retries.
UUIDs help by serving both as the primary key and a time cursor.
For example:
-
Orders / activity feeds / messages (SaaS apps):
Human-readable timestamps are not mandatory in a table. However, you still need time-ordered pages and day/week
ranges.
UUIDv7 enables clean date windows and cursor pagination with just the ID. For example:
Available functions
generate_uuidv7(): generate a version 7 UUID based on the current timeto_uuidv7(): create a version 7 UUID from a Postgres timestampto_uuidv7_boundary(): create a version 7 “boundary” UUID from a Postgres timestampuuid_timestamp(): extract a Postgres timestamp from a version 7 UUIDuuid_timestamp_micros(): extract a Postgres timestamp with microsecond precision from a version 7 UUIDuuid_version(): extract the version of a UUID