X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id 8946B30DD24 for ; Wed, 18 Jun 2003 15:18:51 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 65396-09 for ; Wed, 18 Jun 2003 12:18:41 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id D119930DCE8 for ; Wed, 18 Jun 2003 12:18:40 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h5IFIdU6021751; Wed, 18 Jun 2003 11:18:40 -0400 (EDT) To: Bruno Wolff III Cc: pgsql-performance@postgresql.org Subject: Re: Recent 7.4 change slowed down a query by a factor of 3 In-reply-to: <20030618150210.GA20603@wolff.to> References: <20030618150210.GA20603@wolff.to> Comments: In-reply-to Bruno Wolff III message dated "Wed, 18 Jun 2003 10:02:10 -0500" Date: Wed, 18 Jun 2003 11:18:39 -0400 Message-ID: <21750.1055949519@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200306/124 X-Sequence-Number: 2208 Bruno Wolff III writes: > The query below was running in a bit under 300ms on a version of 7.4 > from less than a week ago until I updated to the version from last night. > Now it takes about 800ms using a significantly different plan. Something fishy here. Will it use the right plan if you set enable_seqscan off? I did bogus=# create table crate(areaid text, touched timestamp); CREATE TABLE bogus=# create index crate_touched on crate(areaid, touched); CREATE INDEX and then explained your query: GroupAggregate (cost=64.14..66.48 rows=67 width=40) -> Sort (cost=64.14..64.64 rows=200 width=40) Sort Key: (touched >= (('now'::text)::timestamp(6) without time zone + '-2 years'::interval)) -> Subquery Scan current (cost=0.00..56.50 rows=200 width=40) Filter: (touched >= (('now'::text)::timestamp(6) without time zone + '-10 years'::interval)) -> Unique (cost=0.00..54.50 rows=200 width=40) -> Index Scan Backward using crate_touched on crate (cost=0.00..52.00 rows=1000 width=40) which looks perfectly reasonable. Obviously, with no data or statistics the estimates are not to be trusted, but it sure looks to me like CVS tip should still be able to generate the right plan. Did you do a full 'make clean' and rebuild when you updated? regards, tom lane