Re: [PERFORM] Hypothetical suggestions for planner, indexing improvement

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: jim(at)nasby(dot)net
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-performance <pgsql-performance(at)postgresql(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PERFORM] Hypothetical suggestions for planner, indexing improvement
Date: 2003-05-07 05:20:36
Message-ID: 25000.1052284836@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-performance

"Jim C. Nasby" <jim(at)nasby(dot)net> writes:
> On Tue, May 06, 2003 at 09:45:07AM -0400, Tom Lane wrote:
>> RTFM...

> As someone pointed out, the documentation says you can't. In this case
> the docs are wrong (I've added a note).

Perhaps you should have read to the end of the section.

>>> BTW, does postgresql handle IN and EXISTS differently?
>>
>> Yes.
>
> They appear to operate the same... what's different?

Supposing that tab1.col1 contains 1, NULL, 2, then for an outer
table row where col2 = 42

WHERE outer.col2 IN (SELECT col1 FROM tab1)

will yield NULL (not FALSE). But

WHERE EXISTS(SELECT * FROM tab1 WHERE col1 = outer.col2)

will yield FALSE (not NULL).

The distinction doesn't matter at the top level of WHERE, but it
matters a lot underneath a NOT ...

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dave Page 2003-05-07 07:28:50 Re: 7.4 features list
Previous Message Jim C. Nasby 2003-05-07 05:08:01 Re: [PERFORM] Hypothetical suggestions for planner, indexing improvement

Browse pgsql-performance by date

  From Date Subject
Next Message Dennis Björklund 2003-05-07 07:36:52 Re: [PERFORM] Hypothetical suggestions for planner, indexing
Previous Message Jim C. Nasby 2003-05-07 05:08:01 Re: [PERFORM] Hypothetical suggestions for planner, indexing improvement