Re: Interesting Query Performance Question - Mailing list pgsql-admin

From Tom Lane
Subject Re: Interesting Query Performance Question
Date
Msg-id 21222.1289063538@sss.pgh.pa.us
Whole thread Raw
In response to Re: Interesting Query Performance Question  (David W Noon <dwnoon@ntlworld.com>)
List pgsql-admin
David W Noon <dwnoon@ntlworld.com> writes:
> On Sat, 06 Nov 2010 11:59:48 -0400, Tom Lane wrote about Re: [ADMIN]
>> In general, NOT IN is hard to optimize because of its weird behavior
>> for NULLs.  I'd suggest looking into converting the query to use an
>> EXISTS instead.

> I have know about that issue for some years, so I always use a column
> that has been declared NOT NULL for the sub-query.  Does PostgreSQL not
> use that property to bypass the vagaries of NULL in an IN predicate?

No.  It's a reasonable TODO item though.  Up till fairly recently, we
didn't have infrastructure that would allow building plans that depended
for correctness on the existence of a constraint.  (In particular,
I'd want such a plan to get thrown away and redone if someone dropped
the NOT NULL constraint.)  We have most of that now, although it only
works for constraints that have entries in pg_constraint, which NOT NULL
doesn't yet.  Maybe in another few months ...

            regards, tom lane

pgsql-admin by date:

Previous
From: David W Noon
Date:
Subject: Re: Interesting Query Performance Question
Next
From: Viktor Bojović
Date:
Subject: drop table