Skip to content

.tip

· one of the small things

New tables get uuidv7() as the default

Postgres 18 ships uuidv7() in core. It's a UUID with a timestamp prefix, so inserts land at the right edge of the index the way an integer's would, and you keep what mattered about UUIDs: generating keys anywhere, with no collisions when you merge.

id uuid PRIMARY KEY DEFAULT uuidv7()

On an existing v4 table, swapping the default is enough. New pages pack tightly from then on, and a REINDEX CONCURRENTLY later on tidies up the rest.

postgresqlschema-design

Longer version: the post this came from.