X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id BF298D1C4E1 for ; Mon, 11 Aug 2003 15:44:00 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 11589-01 for ; Mon, 11 Aug 2003 12:42:29 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 990D7D1C4BA for ; Mon, 11 Aug 2003 12:43:49 -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 h7BFhkSa002935; Mon, 11 Aug 2003 11:43:46 -0400 (EDT) To: Stef Cc: pgsql-performance@postgresql.org Subject: Re: Analyze makes queries slow... In-reply-to: <20030811155841.483ffd93.svb@ucs.co.za> References: <20030811155841.483ffd93.svb@ucs.co.za> Comments: In-reply-to Stef message dated "Mon, 11 Aug 2003 15:58:41 +0200" Date: Mon, 11 Aug 2003 11:43:45 -0400 Message-ID: <2934.1060616625@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/170 X-Sequence-Number: 2987 Stef writes: > I have attached an sql statement that normally runs under 3 minutes. > That is, until I vacuum analyze the database (or just the tables in the query), > then the same query runs longer than 12 hours, and I have to kill it. Could we see the results of "EXPLAIN ANALYZE", rather than just EXPLAIN, for the un-analyzed case? I won't make you do it for the analyzed case ;-) but when dealing with a plan-selection problem the planner's estimates are obviously not to be trusted. Also, what do you see in pg_stats (after analyzing) for each of the tables used in the query? And what PG version is this, exactly? regards, tom lane PS: in case you don't know this already, an easy way to get back to the un-analyzed state is "DELETE FROM pg_statistics".