Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 5DC23632D97 for ; Mon, 2 Aug 2010 19:19:15 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 75869-02 for ; Mon, 2 Aug 2010 22:19:08 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.anarazel.de (mail.anarazel.de [217.115.131.40]) by mail.postgresql.org (Postfix) with ESMTP id 2AC2E632AF8 for ; Mon, 2 Aug 2010 19:19:07 -0300 (ADT) Received: by mail.anarazel.de (Postfix, from userid 108) id BB160448004; Tue, 3 Aug 2010 00:19:05 +0200 (CEST) Received: from anarazel.de (e178230031.adsl.alicedsl.de [85.178.230.31]) by mail.anarazel.de (Postfix) with ESMTPSA id 5D0B3448003; Tue, 3 Aug 2010 00:19:02 +0200 (CEST) Received: by anarazel.de (Postfix, from userid 1000) id B82CD1C00B2; Tue, 3 Aug 2010 00:19:00 +0200 (CEST) Date: Tue, 3 Aug 2010 00:19:00 +0200 From: Andres Freund To: Maciek Sakrejda Cc: pgsql-performance@postgresql.org Subject: Re: Optimizing NOT IN plans / verify rewrite Message-ID: <20100802221900.GC2892@anarazel.de> References: <20100802195257.GA2892@anarazel.de> <20100802202151.GB2892@anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201008/20 X-Sequence-Number: 39863 On Mon, Aug 02, 2010 at 01:35:13PM -0700, Maciek Sakrejda wrote: > >> All fields involved are declared NOT NULL, but thanks for the heads up. > >Afair the planner doesnt use that atm. > > I was referring to not having to care about the strange NULL semantics > (as per your original comment), since I have no NULLs. Given that, I > think the NOT EXISTS could be a good solution, even on 8.3 (we're > planning to upgrade, but it's not a feasible solution to this > particular problem), no? The point is that only 8.4 will optimize that case properly. 8.3 will generate plans which are inefficient in many (or most) cases for both variants. I would suggest to use manual antijoins...