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 E5ECAD7CF3 for ; Fri, 26 Aug 2005 20:14:02 -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 21118-05 for ; Fri, 26 Aug 2005 23:14:01 +0000 (GMT) Received: from zhonka1.zhonka.net (zhonka1.zhonka.net [66.228.195.5]) by svr1.postgresql.org (Postfix) with ESMTP id 16071D7CD9 for ; Fri, 26 Aug 2005 20:14:00 -0300 (ADT) Received: from wolf.pjkh.com ([66.228.196.74]) by zhonka1.zhonka.net (Post.Office MTA v3.5.3 release 223 ID# 0-58414U4500L450S0V35) with ESMTP id net; Fri, 26 Aug 2005 16:14:03 -0700 Received: from localhost (localhost [127.0.0.1]) by wolf.pjkh.com (Postfix) with ESMTP id 8CDA8584D; Fri, 26 Aug 2005 16:13:56 -0700 (PDT) Received: from wolf.pjkh.com ([127.0.0.1]) by localhost (wolf.pjkh.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 21985-09; Fri, 26 Aug 2005 16:13:56 -0700 (PDT) Received: by wolf.pjkh.com (Postfix, from userid 1000) id 550AF584B; Fri, 26 Aug 2005 16:13:56 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by wolf.pjkh.com (Postfix) with ESMTP id 50FD05773; Fri, 26 Aug 2005 16:13:56 -0700 (PDT) Date: Fri, 26 Aug 2005 16:13:56 -0700 (PDT) From: Philip Hallstrom To: asif ali Cc: pgsql-performance@postgresql.org Subject: Re: Weird performance drop after VACUUM In-Reply-To: <20050826225224.27637.qmail@web35212.mail.mud.yahoo.com> Message-ID: <20050826161119.P22700@wolf.pjkh.com> References: <20050826225224.27637.qmail@web35212.mail.mud.yahoo.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by amavisd-new at pjkh.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=-0.056 required=5 tests=[AWL=-0.056] X-Spam-Level: X-Archive-Number: 200508/459 X-Sequence-Number: 14206 > Hi, > I have the same issue. After doing "VACCUME ANALYZE" > performance of the query dropped. > > Here is the query > explain select * from conversion_table c where > c.conversion_date BETWEEN '2005-06-07' and > '2005-08-17' > > Before "VACCUME ANALYZE" > > "Index Scan using conversion_table_pk on > keyword_conversion_table c (cost=0.00..18599.25 > rows=4986 width=95)" > " Index Cond: ((conversion_date >= > '2005-06-07'::date) AND (conversion_date <= > '2005-08-17'::date))" > > > After "VACCUME ANALYZE" > > > "Seq Scan on conversion_table c (cost=0.00..29990.83 > rows=1094820 width=66)" > " Filter: ((conversion_date >= '2005-06-07'::date) > AND (conversion_date <= '2005-08-17'::date))" > > > I dont know why system is doing "Seq scan" now. I could be wrong as I'm definitely no expert on reading the output of EXPLAIN, but it seems to say that prior to VACUUM it was expecting to retrieve 4986 rows and afterwards expecting to retrieve 1094820 rows. Which is a pretty big difference. So maybe the statistics were just really really off prior to vacuuming and once it did vacuum it realized there would be a lot more matches and since there were a lot more matches the planner decided to do a seq scan since it would be quicker overall... Maybe? Seems I've heard Tom Lane say something to that affect, although much more eloquently :-) -philip