Received: from localhost (unknown [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 33AED9FB3AB for ; Wed, 10 Oct 2007 15:07:39 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 92230-02-2 for ; Wed, 10 Oct 2007 15:07:28 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 459829FB527 for ; Wed, 10 Oct 2007 15:07:34 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.1/8.14.1) with ESMTP id l9AI7U5p020981; Wed, 10 Oct 2007 14:07:30 -0400 (EDT) To: Simon Riggs cc: Kevin Grittner , pgsql-performance@postgresql.org Subject: Re: hashjoin chosen over 1000x faster plan In-reply-to: <1192035955.4233.306.camel@ebony.site> References: <470B99BE.EE98.0025.0@wicourts.gov> <1191997904.4233.125.camel@ebony.site> <470C9813.EE98.0025.0@wicourts.gov> <1192035955.4233.306.camel@ebony.site> Comments: In-reply-to Simon Riggs message dated "Wed, 10 Oct 2007 18:05:55 +0100" Date: Wed, 10 Oct 2007 14:07:30 -0400 Message-ID: <20980.1192039650@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/101 X-Sequence-Number: 27123 Simon Riggs writes: > Basically the planner doesn't ever optimise for the possibility of the > never-executed case because even a single row returned would destroy > that assumption. It's worse than that: the outer subplan *does* return some rows. I suppose that all of them had NULLs in the join keys, which means that (since 8.1 or so) nodeMergejoin discards them as unmatchable. Had even one been non-NULL the expensive subplan would have been run. This seems like too much of a corner case to justify adding a lot of machinery for. regards, tom lane