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 13C73D7686 for ; Fri, 26 Aug 2005 20:26:46 -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 22405-09 for ; Fri, 26 Aug 2005 23:26:43 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 3E944D736E for ; Fri, 26 Aug 2005 20:26:41 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j7QNQgCm019593 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 26 Aug 2005 17:26:44 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j7QNQfrB019672; Fri, 26 Aug 2005 17:26:41 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j7QNQfUM019671; Fri, 26 Aug 2005 17:26:41 -0600 (MDT) (envelope-from mfuhr) Date: Fri, 26 Aug 2005 17:26:41 -0600 From: Michael Fuhr To: asif ali Cc: pgsql-performance@postgresql.org Subject: Re: Weird performance drop after VACUUM Message-ID: <20050826232641.GA19583@winnie.fuhr.org> References: <1125093859.9329.30.camel@localhost.localdomain> <20050826225224.27637.qmail@web35212.mail.mud.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050826225224.27637.qmail@web35212.mail.mud.yahoo.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] X-Spam-Level: X-Archive-Number: 200508/460 X-Sequence-Number: 14207 On Fri, Aug 26, 2005 at 03:52:24PM -0700, asif ali wrote: > I have the same issue. After doing "VACCUME ANALYZE" > performance of the query dropped. Your EXPLAIN output doesn't show the actual query times -- could you post the EXPLAIN ANALYZE output? That'll also show how accurate the planner's row count estimates are. > 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. Notice the row count estimates: 4986 in the "before" query and 1094820 in the "after" query. In the latter, the planner thinks it has to fetch so much of the table that a sequential scan would be faster than an index scan. You can see whether that guess is correct by disabling enable_seqscan to force an index scan. It might be useful to see the output of the following: SET enable_seqscan TO on; SET enable_indexscan TO off; EXPLAIN ANALYZE SELECT ...; SET enable_seqscan TO off; SET enable_indexscan TO on; EXPLAIN ANALYZE SELECT ...; You might also experiment with planner variables like effective_cache_size and random_page_cost to see how changing them affects the query plan. However, be careful of tuning the system based on one query: make sure adjustments result in reasonable plans for many different queries. -- Michael Fuhr