Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 5E33F1337B7D for ; Mon, 17 Jan 2011 12:44:52 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 51322-05 for ; Mon, 17 Jan 2011 16:44:45 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mx3.uci.cu (ns3.uci.cu [200.55.140.180]) by mail.postgresql.org (Postfix) with SMTP id B1E2E1337B3E for ; Mon, 17 Jan 2011 12:44:40 -0400 (AST) Received: (qmail 6477 invoked by uid 507); 17 Jan 2011 16:44:34 -0000 Received: from 10.0.0.185 by ns3.uci.cu (envelope-from , uid 501) with qmail-scanner-2.01st (avp: 5.0.2.0. avp: 3.0. avp: 3.0. spamassassin: 3.0.6. perlscan: 2.01st. Clear:RC:1(10.0.0.185):. Processed in 0.775293 secs); 17 Jan 2011 16:44:34 -0000 Received: from unknown (HELO ucimail4.uci.cu) (10.0.0.185) by 0 with SMTP; 17 Jan 2011 16:44:33 -0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by ucimail4.uci.cu (Postfix) with ESMTP id 4989514FC05B; Mon, 17 Jan 2011 11:52:28 -0500 (CST) X-Virus-Scanned: amavisd-new at uci.cu Received: from ucimail4.uci.cu ([127.0.0.1]) by localhost (ucimail4.uci.cu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WsRVb-Dd-zsm; Mon, 17 Jan 2011 11:52:27 -0500 (CST) Received: from ucimail4.uci.cu (ucimail4.uci.cu [10.0.0.185]) by ucimail4.uci.cu (Postfix) with ESMTP id 2B85714CC091; Mon, 17 Jan 2011 11:52:27 -0500 (CST) Date: Mon, 17 Jan 2011 11:52:27 -0500 (CST) From: "Ing. Marcos Ortiz Valmaseda" To: Achilleas Mantzios Cc: pgsql-performance@postgresql.org Message-ID: <955263366.48014741295283147090.JavaMail.root@ucimail4.uci.cu> In-Reply-To: <359477366.48012291295282927070.JavaMail.root@ucimail4.uci.cu> Subject: Re: "NOT IN" substantially slower in 9.0.2 than 8.3.13 - NOT EXISTS runs fast in both 8.3.13 and 9.0.2 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.0.0.186] X-Mailer: Zimbra 5.0.16_GA_2921.RHEL5_64 (ZimbraWebClient - FF3.0 (Win)/5.0.16_GA_2921.RHEL5_64) 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: 201101/131 X-Sequence-Number: 41918 Query is : SELECT distinct m.id,coalesce(m.givenname,''), coalesce(m.midname,''), m.surname from marinerstates ms,vessels vsl,mariner m=20 WHERE m.id=3Dms.marinerid and ms.vslid=3Dvsl.id=20 AND ms.state=3D'Active' and coalesce(ms.endtime,now())::date >=3D '2006-= 07-15' AND ms.starttime::date <=3D '2007-01-11' AND m.marinertype=3D'Mariner' and m.id=20 NOT IN (SELECT distinct mold.id FROM marinerstates msold, vessels vslold, mariner mold =20 WHERE mold.id=3Dmsold.marinerid=20 AND msold.vslid=3Dvslold.id AND msold.state=3D'Active'=20 AND coalesce(msold.endtime,now())::date >=3D '2006-07-15'=20 AND msold.starttime::date <=3D '2007-01-11'=20 AND EXISTS (SELECT 1=20 FROM marinerstates msold2=20 WHERE msold2.marinerid=3Dmsold.marinerid AND msold2.state=3D'Active'=20 AND msold2.id <> msold.id=20 AND msold2.starttime=3D '2006-07-15' and=20 ms.starttime::date <=3D '2007-01-11' and m.marinertype=3D'Mariner' and NO= T EXISTS=20 (SELECT distinct mold.id from marinerstates msold,vessels vslold,mariner= mold where mold.id=3Dmsold.marinerid and msold.vslid=3Dvslold.id and=20 msold.state=3D'Active' and coalesce(msold.endtime,now())::date >=3D '200= 6-07-15' and msold.starttime::date <=3D '2007-01-11' and=20 exists (select 1 from marinerstates msold2 where msold2.marinerid=3Dmsol= d.marinerid and msold2.state=3D'Active' and msold2.id <> msold.id and=20 msold2.starttime