X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5B116D79F9 for ; Fri, 26 Aug 2005 11:45:14 -0300 (ADT) 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 08460-01 for ; Fri, 26 Aug 2005 14:45:11 +0000 (GMT) Received: from unicorn.rentec.com (unicorn.rentec.com [216.223.240.9]) by svr1.postgresql.org (Postfix) with ESMTP id 64683D79C0 for ; Fri, 26 Aug 2005 11:45:06 -0300 (ADT) Received: from wren.rentec.com (wren.rentec.com [192.5.35.106]) by unicorn.rentec.com (8.13.1/8.12.1) with ESMTP id j7QEj72t013241 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 26 Aug 2005 10:45:09 -0400 (EDT) X-Rentec: external Received: from [172.26.132.145] (hoopoe.rentec.com [172.26.132.145]) by wren.rentec.com (8.13.1/8.12.1) with ESMTP id j7QEj7wf029455 for ; Fri, 26 Aug 2005 10:45:07 -0400 (EDT) Message-ID: <430F2AF3.1080704@rentec.com> Date: Fri, 26 Aug 2005 10:45:07 -0400 From: Alan Stange Reply-To: stange@rentec.com Organization: Renaissance Technologies Corp. User-Agent: Mozilla Thunderbird 1.0+ (X11/20050712) MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: difference in plan between 8.0 and 8.1? Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Logged: Logged by unicorn.rentec.com as j7QEj72t013241 at Fri Aug 26 10:45:09 2005 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.018 required=5 tests=[AWL=0.018] X-Spam-Level: X-Archive-Number: 200508/438 X-Sequence-Number: 14185 Hello all, I was hoping someone could explain the plan for a statement. We have a table with a column of longs being used as an index. The query plan in 8.0 was like this: # explain select distinct timeseriesid from tbltimeseries where timeseriesid > 0 order by timeseriesid; SET QUERY PLAN ------------------------------------------------------------------------------------------------------- Unique (cost=0.00..15065908.60 rows=10854026 width=8) -> Index Scan using idx_timeseris on tbltimeseries (cost=0.00..15038773.53 rows=10854026 width=8) Index Cond: (timeseriesid > 0) (3 rows) In 8.1, (using the same database after a dump+restore+vacuum+analyze) I get the following: # explain select distinct timeseriesid from tbltimeseries where timeseriesid > 0 order by timeseriesid; QUERY PLAN --------------------------------------------------------------------------------------------------- Unique (cost=2717137.08..2771407.21 rows=10854026 width=8) -> Sort (cost=2717137.08..2744272.14 rows=10854026 width=8) Sort Key: timeseriesid -> Bitmap Heap Scan on tbltimeseries (cost=48714.09..1331000.42 rows=10854026 width=8) Recheck Cond: (timeseriesid > 0) -> Bitmap Index Scan on idx_timeseris (cost=0.00..48714.09 rows=10854026 width=0) Index Cond: (timeseriesid > 0) (7 rows) I'm hoping someone can explain the new query plan (as I'm not sure I understand what it is doing). Thanks! -- Alan