Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 39A101337BED for ; Wed, 11 May 2011 22:14:30 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 52564-08 for ; Thu, 12 May 2011 01:14:22 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp-2.01.com (smtp-2.01.com [38.102.63.181]) by mail.postgresql.org (Postfix) with ESMTP id C48921337BE1 for ; Wed, 11 May 2011 22:14:22 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp-2.01.com (Postfix) with ESMTP id 46CF31AD92A for ; Wed, 11 May 2011 20:14:23 -0500 (CDT) Received: from smtp-2.01.com ([127.0.0.1]) by localhost (smtp-2.01.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bsI4R08N8BZK for ; Wed, 11 May 2011 20:14:23 -0500 (CDT) Received: by smtp-2.01.com (Postfix, from userid 99) id 2D23F1AD9E1; Wed, 11 May 2011 20:14:23 -0500 (CDT) Received: from Sidney-Stratton.local (70-36-143-243.dsl.dynamic.sonic.net [70.36.143.243]) by smtp-2.01.com (Postfix) with ESMTPSA id E452F1AD92A for ; Wed, 11 May 2011 20:14:22 -0500 (CDT) Message-ID: <4DCB346E.8070608@agliodbs.com> Date: Wed, 11 May 2011 18:14:22 -0700 From: Josh Berkus Organization: PostgreSQL Experts Inc. User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.15) Gecko/20110303 Lightning/1.0b2 Thunderbird/3.1.9 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Postgres refusing to use >1 core References: <4DC81A3F020000250003D433@gw.wicourts.gov> <4DC81D56020000250003D438@gw.wicourts.gov> <4DC8B893.3060908@postnewspapers.com.au> <4DC9E7C5.9080309@postnewspapers.com.au> <4DCAB3A1.2090507@peak6.com> <201105111953.060147@ms14.lnh.mail.rcn.net> <4DCB0802.9060505@peak6.com> In-Reply-To: <4DCB0802.9060505@peak6.com> X-Enigmail-Version: 1.1.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201105/162 X-Sequence-Number: 43671 On 5/11/11 3:04 PM, Shaun Thomas wrote: > The original query, with our very large tables, ran for over *two hours* > thanks to a nested loop iterating over the subquery. My replacement ran > in roughly 30 seconds. If we were using a newer version of PG, we could > have used a CTE. But do you get what I mean? Temp tables are a fairly > common technique, but how would a coder know about CTEs? They're pretty > new, even to *us*. For that matter, it would be even better if PostgreSQL realized that a materialize of the subquery was a better execution plan, and just did it for you. -- Josh Berkus PostgreSQL Experts Inc. http://pgexperts.com