Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id EF82E9FB2C0 for ; Thu, 1 Mar 2007 18:37:00 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-new, port 10024) with ESMTP id 37197-06 for ; Thu, 1 Mar 2007 18:36:54 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from 66-226-76-106.dedicated.abac.net (66-226-76-106.dedicated.abac.net [66.226.76.106]) by postgresql.org (Postfix) with ESMTP id 62C0F9FA4F3 for ; Thu, 1 Mar 2007 18:36:57 -0400 (AST) Received: (qmail 9534 invoked by uid 2020); 1 Mar 2007 14:36:55 -0800 Received: from wsip-70-167-125-69.sd.sd.cox.net (HELO ?192.168.0.3?) (70.167.125.69) by 192.168.0.4 with (DHE-RSA-AES256-SHA encrypted) SMTP; 1 Mar 2007 14:36:55 -0800 Message-ID: <45E756A3.5020604@modgraph-usa.com> Date: Thu, 01 Mar 2007 14:41:39 -0800 From: "Craig A. James" User-Agent: Thunderbird 1.5.0.9 (X11/20061206) MIME-Version: 1.0 To: Stephan Szabo CC: pgsql-performance@postgresql.org Subject: Re: Identical Queries References: <45E6F49D.3010707@callone.net> <20070301112948.R45862@megazone.bigpanda.com> <45E73DA5.40808@callone.net> In-Reply-To: <45E73DA5.40808@callone.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=3.186 tagged_above=0 required=5 tests=AWL, BAYES_50, HELO_DYNAMIC_IPADDR2 X-Spam-Level: *** X-Archive-Number: 200703/28 X-Sequence-Number: 23433 Stephan Szabo wrote: > 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. Even for a temporary table, you should run ANALYZE on it after you fill it but before you query or join to it. I found out (the hard way) that a temporary table of just 100 rows will generate dramatically different plans before and after ANALYZE. Craig