Re: (9.1) btree_gist support for searching on "not equals" - Mailing list pgsql-hackers

From Takahiro Itagaki
Subject Re: (9.1) btree_gist support for searching on "not equals"
Date
Msg-id 20100525100322.CF3F.52131E4D@oss.ntt.co.jp
Whole thread Raw
In response to Re: (9.1) btree_gist support for searching on "not equals"  (Marko Tiikkaja <marko.tiikkaja@cs.helsinki.fi>)
List pgsql-hackers
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




pgsql-hackers by date:

Previous
From: KaiGai Kohei
Date:
Subject: Re: ExecutorCheckPerms() hook
Next
From: KaiGai Kohei
Date:
Subject: Re: ExecutorCheckPerms() hook