Marko Tiikkaja <marko.tiikkaja@cs.helsinki.fi> wrote:
> On 5/21/10 11:47 PM +0300, Jeff Davis wrote:
> > It also allows you to enforce the constraint that only one tuple exists
> > in a table by doing something like:
> >
> > create table a
> > (
> > i int,
> > exclude using gist (i with<>),
> > unique (i)
> > );
+1. I've not read the code, but it might be considerable that we can
abort index scans if we find a first index entry for "i". While we must
scan all candidates for "WHERE i <> ?", but we can abort for the constraint
case because we know existing values are all the same.
> FWIW, this is achievable a lot more easily:
> CREATE UNIQUE INDEX "a_single_row" ON a ((1));
The former exclusion constraint means "one same value for all rows",
but your alternative means "a_single_row", right?
Regards,
---
Takahiro Itagaki
NTT Open Source Software Center