Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 92E069FB773 for ; Wed, 10 Oct 2007 16:01:17 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 62058-08-2 for ; Wed, 10 Oct 2007 16:01:04 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from outmail136072.authsmtp.net (outmail136072.authsmtp.net [62.13.136.72]) by postgresql.org (Postfix) with ESMTP id B1CFB9FB792 for ; Wed, 10 Oct 2007 16:01:03 -0300 (ADT) Received: from outmail128184.authsmtp.net (outmail128184.authsmtp.net [62.13.128.184]) by punt2.authsmtp.com (8.13.8/8.13.8/Kp) with ESMTP id l9AJ0v1a057911; Wed, 10 Oct 2007 20:00:57 +0100 (BST) Received: from [192.168.0.3] (85-211-149-22.dyn.gotadsl.co.uk [85.211.149.22]) (authenticated bits=0) by mail.authsmtp.com (8.13.8/8.13.8/Kp) with ESMTP id l9AJ0teN017364; Wed, 10 Oct 2007 20:00:56 +0100 (BST) Subject: Re: hashjoin chosen over 1000x faster plan From: Simon Riggs To: Tom Lane Cc: Kevin Grittner , pgsql-performance@postgresql.org In-Reply-To: <20980.1192039650@sss.pgh.pa.us> 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> <20980.1192039650@sss.pgh.pa.us> Content-Type: text/plain Date: Wed, 10 Oct 2007 20:01:03 +0100 Message-Id: <1192042863.4233.340.camel@ebony.site> Mime-Version: 1.0 X-Mailer: Evolution 2.8.2 Content-Transfer-Encoding: 7bit X-Server-Quench: 220ffb9b-7763-11dc-b86a-001185d377ca X-AuthRoute: OCdxZQATClZOTQEd DAteCiNZVAwpPBRK HVkIKg5MJUcNSQVJ NksadRtFaQVbYlpF HGQLW1NEUl17WWN/ bg0fZQBDYEtPQQRu WVZLQE1QERpoT0AI d2QeFkwMdwRBe3h0 K0dlVnEVXkZ6IxAv SxxJEmoAZnphaTRM TRJQcVJJcANLfxdA PlN4UyBcLwdSbGoL JyIJERcLGAAXKC1O QgMKLFRaSkYMBTM6 DxccEC9nRBVdHzV7 IRU9NlMGVF4VO0Na X-Authentic-SMTP: 61633235383639.squirrel.dmpriest.net.uk:752/Kp X-Report-SPAM: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-Virus-Status: No virus detected - but ensure you scan with your own anti-virus system! X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/104 X-Sequence-Number: 27126 On Wed, 2007-10-10 at 14:07 -0400, Tom Lane wrote: > 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. Yup > This seems like too much of a corner case to justify adding a lot of > machinery for. Well, I thought about that and it is pretty common to have root classes left outer joined to sub-classes, if you are using the One Table per Subclass object-relational mapping. The joined-subclass mapping within Hibernate implements this. Not everybody uses that, but it is an option some people take in some circumstances. So we should keep it on our radar if we want to extend our for support complex applications. -- Simon Riggs 2ndQuadrant http://www.2ndQuadrant.com