X-Original-To: pgsql-hackers@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 35027476315; Wed, 7 May 2003 01:20:41 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id EA6A5476178; Wed, 7 May 2003 01:20:39 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h475KaU6025001; Wed, 7 May 2003 01:20:36 -0400 (EDT) To: jim@nasby.net Cc: Josh Berkus , pgsql-performance , pgsql-hackers@postgresql.org Subject: Re: [PERFORM] Hypothetical suggestions for planner, indexing improvement 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> Comments: In-reply-to "Jim C. Nasby" message dated "Wed, 07 May 2003 00:08:01 -0500" Date: Wed, 07 May 2003 01:20:36 -0400 Message-ID: <25000.1052284836@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.3 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200305/140 X-Sequence-Number: 38647 "Jim C. Nasby" 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