Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 24C97633722 for ; Mon, 2 Aug 2010 16:53:13 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 04135-04-2 for ; Mon, 2 Aug 2010 19:53:05 +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 78CF6633032 for ; Mon, 2 Aug 2010 16:53:05 -0300 (ADT) Received: by mail.anarazel.de (Postfix, from userid 108) id DC898448007; Mon, 2 Aug 2010 21:53:02 +0200 (CEST) Received: from anarazel.de (e178230031.adsl.alicedsl.de [85.178.230.31]) by mail.anarazel.de (Postfix) with ESMTPSA id 0FFCA448005; Mon, 2 Aug 2010 21:52:59 +0200 (CEST) Received: by anarazel.de (Postfix, from userid 1000) id 6241F1C00A7; Mon, 2 Aug 2010 21:52:57 +0200 (CEST) Date: Mon, 2 Aug 2010 21:52:57 +0200 From: Andres Freund To: Maciek Sakrejda Cc: pgsql-performance@postgresql.org Subject: Re: Optimizing NOT IN plans / verify rewrite Message-ID: <20100802195257.GA2892@anarazel.de> References: 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/11 X-Sequence-Number: 39854 Hi, On Mon, Aug 02, 2010 at 12:12:51PM -0700, Maciek Sakrejda wrote: > I'm running PostgreSQL 8.3 and I have a query with a couple of NOT IN > subqueries: With 8.3 you will have to use manual antijoins (i.e LEFT JOIN ... WHERE NULL). If you use 8.4 NOT EXISTS() will do that automatically in many cases (contrary to NOT IN () which has strange NULL semantics). Anbdres