X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 589F6D1B46A for ; Mon, 12 Jan 2004 02:56:00 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 63726-04 for ; Sun, 11 Jan 2004 22:55:32 -0400 (AST) Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) by svr1.postgresql.org (Postfix) with ESMTP id 6610FD1D576 for ; Sun, 11 Jan 2004 22:55:28 -0400 (AST) Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) by smtp.istop.com (Postfix) with ESMTP id EC9B436AA6; Sun, 11 Jan 2004 21:55:26 -0500 (EST) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com ident=foobar) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1AfsEg-0006J8-00; Sun, 11 Jan 2004 21:55:26 -0500 To: Richard van den Berg Cc: pgsql-performance@postgresql.org Subject: Re: Explain not accurate References: <3FFEB6DA.8000905@trust-factory.com> In-Reply-To: <3FFEB6DA.8000905@trust-factory.com> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 11 Jan 2004 21:55:26 -0500 Message-ID: <87smil3mg1.fsf@stark.xeocode.com> Lines: 27 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/115 X-Sequence-Number: 5290 Richard van den Berg writes: > Hi there, > > I am quite new to postgresql, and love the explain feature. It enables us to > predict which SQL queries needs to be optimized before we see any problems. > However, I've run into an issue where explain tells us a the costs of a quiry > are tremendous (105849017586), but the query actually runs quite fast. Even > "explain analyze" shows these costs. Do you have any of the optimization parameters off, enable_seqscan perhaps? enable_seqscan works by penalizing plans that use sequential plans, but there are still lots of queries that cannot be done any other way. I'm not sure whether the same holds for all the other parameters. If your tables are all going to grow drastically then this may still indicate a problem, probably a missing index. But if one of them is a reference table that will never grow then perhaps the index will never be necessary. Or perhaps you just need to run analyze. Send the "EXPLAIN ANALYZE" output for the query for starters. You might also send the output of "SHOW ALL". -- greg