X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EE0853A2CF0 for ; Sat, 15 Jan 2005 20:53:42 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 52678-09 for ; Sat, 15 Jan 2005 20:53:38 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id DB2183A2C9F for ; Sat, 15 Jan 2005 20:53:39 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j0FKrbYg011486; Sat, 15 Jan 2005 15:53:37 -0500 (EST) To: Josh Berkus Cc: pgsql-performance@postgresql.org Subject: Re: IN() Optimization issue in 8.0rc5 In-reply-to: <200501151223.10372.josh@agliodbs.com> References: <200501151223.10372.josh@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Sat, 15 Jan 2005 12:23:10 -0800" Date: Sat, 15 Jan 2005 15:53:37 -0500 Message-ID: <11485.1105822417@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200501/197 X-Sequence-Number: 9887 Josh Berkus writes: > dm=# explain > dm-# SELECT personid FROM mr.person_attributes_old > dm-# WHERE personid NOT IN (SELECT > personid FROM mr.person_attributes); > QUERY PLAN > ----------------------------------------------------------------------------------- > Seq Scan on person_attributes_old (cost=0.00..3226144059.85 rows=235732 > width=4) > Filter: (NOT (subplan)) > SubPlan > -> Seq Scan on person_attributes (cost=0.00..12671.07 rows=405807 > width=4) > (4 rows) Hmm. What you want for a NOT IN is for it to say Filter: (NOT (hashed subplan)) which you are not getting. What's the datatypes of the two personid columns? Is the 400k-row estimate for person_attributes reasonable? Maybe you need to increase work_mem (nee sort_mem) to allow a 400k-row hash table? regards, tom lane