Re: Proposal: Add a UNIQUE NOT ENFORCED constraint

From: "Joel Jacobson" <joel(at)compiler(dot)org>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Proposal: Add a UNIQUE NOT ENFORCED constraint
Date: 2026-01-06 06:43:07
Message-ID: adbac78c-1aa0-4301-b8a8-6f79064d567b@app.fastmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Jan 4, 2026, at 18:34, Jacob Jackson wrote:
> I am working through a case that requires very high throughput inserts
> that would be slowed down by a unique index, but that has externally
> guaranteed unique values and could benefit from the query planning and
> documentation provided by a unique constraint.
>
> To fill this need, I propose adding a UNIQUE NOT ENFORCED constraint,
> which would tell Postgres to assume uniqueness without creating a
> unique index to enforce it, leaving ensuring uniqueness to the
> developer, similar to unenforced CHECK and foreign key constraints
> (https://commitfest.postgresql.org/patch/5285/)

Can you please share some more details on your use-case?
I'm curious to learn more about this "unique" column.
Don't you ever need to do lookups/joins on it (e.g. WHERE col = ?)?

/Joel

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message VASUKI M 2026-01-06 06:49:14 Re: [PATCH] psql: tab completion for ALTER ROLE ... IN DATABASE ...
Previous Message Japin Li 2026-01-06 06:27:30 Re: [PATCH] Add pg_get_role_ddl() functions for role recreation