Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 69CB16507D2 for ; Tue, 2 Sep 2008 15:40:48 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 57562-06-4 for ; Tue, 2 Sep 2008 15:40:42 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 2AFF66507DA for ; Tue, 2 Sep 2008 14:18:52 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m82HIbhm016038; Tue, 2 Sep 2008 13:18:37 -0400 (EDT) To: Simon Riggs cc: List pgsql-patches Subject: Re: WIP Join Removal In-reply-to: <1220375620.4371.479.camel@ebony.2ndQuadrant> References: <1220176372.4371.118.camel@ebony.2ndQuadrant> <15179.1220372890@sss.pgh.pa.us> <1220375620.4371.479.camel@ebony.2ndQuadrant> Comments: In-reply-to Simon Riggs message dated "Tue, 02 Sep 2008 18:13:40 +0100" Date: Tue, 02 Sep 2008 13:18:37 -0400 Message-ID: <16037.1220375917@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200809/28 X-Sequence-Number: 7043 Simon Riggs writes: > On Tue, 2008-09-02 at 12:28 -0400, Tom Lane wrote: >> I haven't thought this through entirely, but wouldn't a partial index be >> okay if it's marked predOK? You might be right that the case is >> unlikely, but if it's only one extra line to support it ... > As of now, its it is predOK then that implies there was a qual on the > checkrel so can't remove the join. That conclusion seems utterly wrong to me. Per the example of a left join b on (a.x = b.y and b.z = 1) b.z = 1 will bubble down to be a qual on b. It doesn't prevent the join optimization, and it does possibly allow the use of a partial index. In particular a unique index on b.y with a predicate involving b.z would be relevant to the optimization decision here. In slightly more realistic cases, b might be a view on c that imposes a WHERE condition on c.z, so that's another avenue for a qual to exist below the join. regards, tom lane