Re: Proposal: Add a UNIQUE NOT ENFORCED constraint - Mailing list pgsql-hackers

From Joel Jacobson
Subject Re: Proposal: Add a UNIQUE NOT ENFORCED constraint
Date
Msg-id adbac78c-1aa0-4301-b8a8-6f79064d567b@app.fastmail.com
Whole thread Raw
In response to Proposal: Add a UNIQUE NOT ENFORCED constraint  (Jacob Jackson <jej.jackson.08@gmail.com>)
Responses Re: Proposal: Add a UNIQUE NOT ENFORCED constraint
List 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



pgsql-hackers by date:

Previous
From: Japin Li
Date:
Subject: Re: [PATCH] Add pg_get_role_ddl() functions for role recreation
Next
From: VASUKI M
Date:
Subject: Re: [PATCH] psql: tab completion for ALTER ROLE ... IN DATABASE ...