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 D1E04D96AD for ; Fri, 11 Nov 2005 15:32:11 -0400 (AST) 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 11333-03 for ; Fri, 11 Nov 2005 19:32:09 +0000 (GMT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 1BEB6D6D1D for ; Fri, 11 Nov 2005 15:32:09 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id jABJWAM3021007; Fri, 11 Nov 2005 14:32:10 -0500 (EST) To: dwinner-lists@att.net cc: pgsql-performance@postgresql.org Subject: Re: slow queries after ANALYZE In-reply-to: <4374EDF1.5010709@att.net> References: <4374EDF1.5010709@att.net> Comments: In-reply-to DW message dated "Fri, 11 Nov 2005 14:16:01 -0500" Date: Fri, 11 Nov 2005 14:32:10 -0500 Message-ID: <21006.1131737530@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.006 required=5 tests=[AWL=0.006] X-Spam-Score: 0.006 X-Spam-Level: X-Archive-Number: 200511/214 X-Sequence-Number: 15471 DW writes: > I'm perplexed. I'm trying to find out why some queries are taking a long > time, and have found that after running analyze, one particular query > becomes slow. This implies that the planner's default choice of plan (without any statistics) is better than its choice when informed by statistics. This is undesirable but not unheard of :-( It would be interesting to see EXPLAIN ANALYZE results in both cases, plus the contents of the relevant pg_stats rows. (BTW, you need not dump and reload to get back to the virgin state --- just delete the relevant rows from pg_statistic.) Also we'd want to know exactly what PG version this is, and on what sort of platform. You might be able to fix things by increasing the statistics targets or tweaking planner cost parameters, but it'd be best to investigate before trying to fix. regards, tom lane