Re: FK index q'n

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: rihad <rihad(at)mail(dot)ru>, pgsql-general(at)postgresql(dot)org
Subject: Re: FK index q'n
Date: 2007-11-30 16:04:27
Message-ID: 20071130160427.GA21481@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom Lane wrote:
> rihad <rihad(at)mail(dot)ru> writes:
> > Given this table:
> > CREATE TABLE foo (
> > id integer primary key,
> > bar_id integer references bar (id)
> > );
> > and provided that bar.id is itself a PK, do I still need to create an
> > index on bar_id if often doing queries like:
> > SELECT MIN(id) FROM foo WHERE bar_id IS NULL;
>
> Now as far as the above-illustrated query goes, no simple index is going
> to help it, because IS NULL is not an indexable operation.

Unless you are on 8.3, that is.

--
Alvaro Herrera http://www.amazon.com/gp/registry/CTMLCN8V17R4
Y dijo Dios: "Que sea Satanás, para que la gente no me culpe de todo a mí."
"Y que hayan abogados, para que la gente no culpe de todo a Satanás"

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Gregory Stark 2007-11-30 16:06:38 Re: postgresql table inheritance
Previous Message Gregory Stark 2007-11-30 15:59:59 Re: Recheck condition