Re: Unique constraints and indexes.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Steve Rogerson <steve(dot)pg(at)yewtc(dot)demon(dot)co(dot)uk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Unique constraints and indexes.
Date: 2016-01-05 20:23:15
Message-ID: 12685.1452025395@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Steve Rogerson <steve(dot)pg(at)yewtc(dot)demon(dot)co(dot)uk> writes:
> On 05/01/16 19:47, Tom Lane wrote:
>> That's operating as designed. A unique constraint needs an index,
>> but not vice versa.

> I can see that might be plausible , hence the question but as a "unique index"
> imposes as constraint they seem equivalent. What's the functional difference
> between the two situations?

There is none so far as uniqueness-enforcement is concerned, because the
index is the same either way, and that's what enforces it.

The main reason we don't automatically create a constraint for every
unique index is that not all index declarations can be represented
by SQL-standard constraints.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Kevin Grittner 2016-01-05 21:03:32 Re: A unique pairs version of UNNEST() ?
Previous Message David G. Johnston 2016-01-05 20:13:52 Re: Unique constraints and indexes.