Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id B80E11337B2F for ; Fri, 21 Jan 2011 13:09:21 -0400 (AST) 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 90445-04 for ; Fri, 21 Jan 2011 17:09:14 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-yw0-f46.google.com (mail-yw0-f46.google.com [209.85.213.46]) by mail.postgresql.org (Postfix) with ESMTP id 86EDE1336FA7 for ; Fri, 21 Jan 2011 13:09:13 -0400 (AST) Received: by ywe10 with SMTP id 10so212365ywe.19 for ; Fri, 21 Jan 2011 09:09:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=toxecRvwj7U3diyLPym4l0uAIz1nbAjY3d3YxA0DutU=; b=CuDF+Zva+fjsWh2pbkV/RVFyvW+2UhpXPfkaFBjOkhaQsXVF50qzfsNUFhp22pCLYr 7FfZhjWoDdi7WlOEovgTE9Nwse+jwpsSWYEiMP+fkw5IfRq6uCCuVL4gLVeINZ5Sn4kA cbnjjnz+sgjp6jT8/O5Rpg6xQFKgid38EWXVc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=los6xHGepbLx+d1HVZmg8BcCXJKRa62mR3HO7HZutYM3PJ9mcvy/ZtqJHnuhatx7WJ XU6Rl6EzkYWEGMrwRIFSAXltG/IVLdc6RJTzQKt4/1wxhGj/klQEMqUk8RJTxgIdXNyu xjQWTBXp49iUpcAriK3pQXCiylMT6acQvnSSY= MIME-Version: 1.0 Received: by 10.42.240.195 with SMTP id lb3mr1079413icb.343.1295629752474; Fri, 21 Jan 2011 09:09:12 -0800 (PST) Received: by 10.42.172.4 with HTTP; Fri, 21 Jan 2011 09:09:12 -0800 (PST) In-Reply-To: <201101200905.26400.achill@matrix.gatewaynet.com> References: <955263366.48014741295283147090.JavaMail.root@ucimail4.uci.cu> <201101191110.05268.achill@matrix.gatewaynet.com> <21792.1295458016@sss.pgh.pa.us> <201101200905.26400.achill@matrix.gatewaynet.com> Date: Fri, 21 Jan 2011 12:09:12 -0500 Message-ID: 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 From: Robert Haas To: Achilleas Mantzios Cc: pgsql-performance@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7 X-Spam-Level: X-Archive-Number: 201101/193 X-Sequence-Number: 41980 On Thu, Jan 20, 2011 at 2:05 AM, Achilleas Mantzios wrote: > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 -> =A0Hash Semi Join =A0(cost=3D2768.00..56= 71.67 rows=3D1 width=3D12) (actual time=3D39.249..81.025 rows=3D1876 loops= =3D1) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Hash Cond: (msold.marinerid =3D= msold2.marinerid) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Join Filter: ((msold2.id <> mso= ld.id) AND (msold2.starttime < msold.starttime) AND ((msold.starttime - mso= ld2.endtime) <=3D '1 year 6 mons'::interval)) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 -> =A0Seq Scan on marinerstates= msold =A0(cost=3D0.00..2889.32 rows=3D4590 width=3D20) (actual time=3D0.00= 3..33.964 rows=3D2625 loops=3D1) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Filter: (((state)::= text =3D 'Active'::text) AND ((starttime)::date <=3D '2007-01-11'::date) AN= D ((COALESCE(endtime, now()))::date >=3D '2006-07-15'::date)) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 -> =A0Hash =A0(cost=3D2251.66..= 2251.66 rows=3D41307 width=3D24) (actual time=3D39.156..39.156 rows=3D41250= loops=3D1) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Buckets: 8192 =A0Ba= tches: 1 =A0Memory Usage: 2246kB > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 -> =A0Seq Scan on m= arinerstates msold2 =A0(cost=3D0.00..2251.66 rows=3D41307 width=3D24) (actu= al time=3D0.002..24.552 rows=3D41250 loops=3D1) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Filter:= ((state)::text =3D 'Active'::text) Looks like the bad selectivity estimate there is what's killing it. Not sure I completely understand why 9.0.2 is coming up with such a bad estimate, though. --=20 Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company