Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 2715A9FB427 for ; Mon, 21 May 2007 18:32:14 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 84989-05 for ; Mon, 21 May 2007 18:32:10 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 616669FB402 for ; Mon, 21 May 2007 18:32:09 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.1/8.14.1) with ESMTP id l4LLW59R029046; Mon, 21 May 2007 17:32:05 -0400 (EDT) To: pgsql-performance@nullmx.com cc: pgsql-performance@postgresql.org Subject: Re: Rewriting DISTINCT and losing performance In-reply-to: <200705211217.45205.pgsql-performance@nullmx.com> References: <200705202228.32129.pgsql-performance@nullmx.com> <200705210909.44335.pgsql-performance@nullmx.com> <4651D813.5050100@archonet.com> <200705211217.45205.pgsql-performance@nullmx.com> Comments: In-reply-to "Chuck D." message dated "Mon, 21 May 2007 12:17:44 -0600" Date: Mon, 21 May 2007 17:32:05 -0400 Message-ID: <29045.1179783125@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/405 X-Sequence-Number: 24795 "Chuck D." writes: > Doesn't that seem a bit strange? Does it have to do with the smaller size of > the new table maybe? No, it seems to be a planner bug: http://archives.postgresql.org/pgsql-hackers/2007-05/msg00920.php I imagine that your table statistics are close to the critical point where a bitmap scan looks cheaper or more expensive than a plain index scan, and so the chosen plan varies depending on more-or-less chance factors. Certainly getting rid of NULLs shouldn't have had any direct impact on this choice. regards, tom lane