pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: jim@nasby.net
Cc: Josh Berkus <josh@agliodbs.com>
Cc: pgsql-performance <pgsql-performance@postgresql.org>
Cc: pgsql-hackers@postgresql.org
Subject: Re: [PERFORM] Hypothetical suggestions for planner, indexing improvement
Date: Wed, 07 May 2003 01:20:36 -0400
Message-ID: <25000.1052284836@sss.pgh.pa.us> (raw)
In-Reply-To: <20030507000801.E66185@flake.decibel.org>
References: <200305051219.58955.josh@agliodbs.com>
	<22292.1052195133@sss.pgh.pa.us>
	<200305052133.33680.josh@agliodbs.com>
	<20030506080747.C66185@flake.decibel.org>
	<24779.1052228707@sss.pgh.pa.us>
	<20030507000801.E66185@flake.decibel.org>

"Jim C. Nasby" <jim@nasby.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




view thread (16+ messages)  latest in thread

Message-ID: <25000.1052284836@sss.pgh.pa.us>
Permalink:  ../25000.1052284836@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/25000.1052284836@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, jim@nasby.net, josh@agliodbs.com, pgsql-hackers@postgresql.org
  Subject: Re: [PERFORM] Hypothetical suggestions for planner, indexing improvement
  In-Reply-To: <25000.1052284836@sss.pgh.pa.us>
  References: <200305051219.58955.josh@agliodbs.com> <22292.1052195133@sss.pgh.pa.us> <200305052133.33680.josh@agliodbs.com> <20030506080747.C66185@flake.decibel.org> <24779.1052228707@sss.pgh.pa.us> <20030507000801.E66185@flake.decibel.org> <25000.1052284836@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox