X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 55BF39DCBD2 for ; Wed, 1 Feb 2006 16:14:47 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 24952-04 for ; Wed, 1 Feb 2006 16:14:47 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id C0C439DCB4B for ; Wed, 1 Feb 2006 16:14:44 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id k11KEjkY004219; Wed, 1 Feb 2006 15:14:45 -0500 (EST) To: "Kevin Grittner" cc: pgsql-performance@postgresql.org Subject: Re: Planner reluctant to start from subquery In-reply-to: <43E0BEDD.EE98.0025.0@wicourts.gov> References: <43E0AA7E.EE98.0025.0@wicourts.gov><43E0AA7E.EE98.0025.0@wicourts.gov> <3759.1138822464@sss.pgh.pa.us> <43E0BEDD.EE98.0025.0@wicourts.gov> Comments: In-reply-to "Kevin Grittner" message dated "Wed, 01 Feb 2006 13:59:57 -0600" Date: Wed, 01 Feb 2006 15:14:45 -0500 Message-ID: <4218.1138824885@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.103 required=5 tests=[AWL=0.103] X-Spam-Score: 0.103 X-Spam-Level: X-Archive-Number: 200602/22 X-Sequence-Number: 17008 "Kevin Grittner" writes: > Tom Lane wrote: >> ... expected an equivalent IN clause to work better. In fact, I'm not >> clear why the planner isn't finding the cheapest plan (which it does >> estimate as cheapest) from the IN version you posted. > All I know is that trying various permutations, I saw it pick a good > plan for the IN format when I eliminated the last outer join in the FROM > clause. I know it isn't conclusive, but it was a correlation which > suggested a possible causality to me. But there is still an outer join in your third example (the one with the best plan), so that doesn't seem to hold water. In any case, the way that IN planning works these days it really should have considered the plan equivalent to your JOIN-against-GROUP-BY variant. I'm interested to poke at this ... are you in a position to provide a test case? regards, tom lane