Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 2A6429FB56B for ; Thu, 1 Mar 2007 15:39:22 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 42706-07 for ; Thu, 1 Mar 2007 15:39:10 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by postgresql.org (Postfix) with ESMTP id 6823A9FB596 for ; Thu, 1 Mar 2007 15:39:10 -0400 (AST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 6317B35373; Thu, 1 Mar 2007 11:39:09 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 61B9335368; Thu, 1 Mar 2007 11:39:09 -0800 (PST) Date: Thu, 1 Mar 2007 11:39:09 -0800 (PST) From: Stephan Szabo To: Rob Schall Cc: pgsql-performance@postgresql.org Subject: Re: Identical Queries In-Reply-To: <45E6F49D.3010707@callone.net> Message-ID: <20070301112948.R45862@megazone.bigpanda.com> References: <45E6F49D.3010707@callone.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.076 tagged_above=0 required=5 tests=AWL, BAYES_50 X-Spam-Level: X-Archive-Number: 200703/11 X-Sequence-Number: 23416 On Thu, 1 Mar 2007, Rob Schall wrote: > Question for anyone... > > I tried posting to the bugs, and they said this is a better question for here. > I have to queries. One runs in about 2 seconds. The other takes upwards > of 2 minutes. I have a temp table that is created with 2 columns. This > table is joined with the larger database of call detail records. > However, these 2 queries are handled very differently. How many rows are there in anitmp and how many rows in anitmp have istf=true and how many have istf=false? If you don't currently analyze the temp table after adding the rows, you might find that doing an analyze helps, or at least makes the row estimates better.