Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id E72A41337B43 for ; Tue, 18 Jan 2011 14:57:07 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 11343-06 for ; Tue, 18 Jan 2011 18:57:00 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sam.nabble.com (sam.nabble.com [216.139.236.26]) by mail.postgresql.org (Postfix) with ESMTP id 7D4521337999 for ; Tue, 18 Jan 2011 14:57:00 -0400 (AST) Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.69) (envelope-from ) id 1PfGjj-0006KQ-Cc for pgsql-performance@postgresql.org; Tue, 18 Jan 2011 10:56:59 -0800 Date: Tue, 18 Jan 2011 10:56:59 -0800 (PST) From: masterchief To: pgsql-performance@postgresql.org Message-ID: <1295377019385-3346652.post@n5.nabble.com> In-Reply-To: <4CFFEBB5.8090401@obviously.com> References: <4CFFD446.6040609@obviously.com> <4CFFEBB5.8090401@obviously.com> Subject: Re: hashed subplan 5000x slower than two sequential operations MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.778 tagged_above=-10 required=5 tests=BAYES_00=-1.9, URI_HEX=1.122 X-Spam-Level: X-Archive-Number: 201101/151 X-Sequence-Number: 41938 > Tom Lane wrote: > > The only really effective way the planner knows to optimize an > "IN (sub-SELECT)" is to turn it into a semi-join, which is not possible > here because of the unrelated OR clause. You might consider replacing > this with a UNION of two scans of "contexts". (And yes, I know it'd be > nicer if the planner did that for you.) In moving our application from Oracle to Postgres, we've discovered that a large number of our reports fall into this category. If we rewrite them as a UNION of two scans, it would be quite a big undertaking. Is there a way to tell the planner explicitly to use a semi-join (I may not grasp the concepts here)? If not, would your advice be to hunker down and rewrite the queries? -- View this message in context: http://postgresql.1045698.n5.nabble.com/hashed-subplan-5000x-slower-than-two-sequential-operations-tp3297790p3346652.html Sent from the PostgreSQL - performance mailing list archive at Nabble.com.