scribase
Data typesversion 1.7

pg_uuidv7

Time-ordered UUID v7 values.

What it is for

UUID v7 starts with a millisecond timestamp, so new ids sort after old ones. As a primary key that keeps B-tree inserts at the right edge of the index instead of scattered, which means less index bloat and better cache use than random v4 ids. Postgres 17 has no built-in v7 generator; this extension adds one.

Enable it

sql
create extension if not exists pg_uuidv7 with schema extensions;

Example

sql
create table orders (
  id uuid primary key default uuid_generate_v7(),
  total_cents int not null
);

select id, uuid_v7_to_timestamptz(id) as created_at from orders order by id desc limit 5;

Questions

How do I enable pg_uuidv7?

Run create extension if not exists pg_uuidv7 with schema extensions; in the SQL editor, or switch it on from the Extensions page in the console. You do not need superuser access.

Which version of pg_uuidv7 is installed?

1.7, on Postgres 17.6, as read from the running engine on 2026-10-08. Check yours with: select extversion from pg_extension where extname = 'pg_uuidv7';

Upstream project: github.com/fboulnois/pg_uuidv7

More data types extensions

  • uuid-ossp UUID generators (v1 to v5).
  • citext Case-insensitive text, for emails and user names.
  • hstore Key-value pairs in one column.
  • ltree Tree paths such as categories and org charts.
  • intarray Functions and indexes for integer arrays.
  • cube Multi-dimensional points and boxes.