Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 2865C6501F1 for ; Mon, 1 Sep 2008 16:23:29 -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 77621-02 for ; Mon, 1 Sep 2008 16:23:23 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from ey-out-2122.google.com (ey-out-2122.google.com [74.125.78.24]) by postgresql.org (Postfix) with ESMTP id 08A1664FD19 for ; Mon, 1 Sep 2008 16:23:24 -0300 (ADT) Received: by ey-out-2122.google.com with SMTP id 6so752452eyi.61 for ; Mon, 01 Sep 2008 12:23:22 -0700 (PDT) Received: by 10.210.26.10 with SMTP id 10mr6988792ebz.63.1220297002210; Mon, 01 Sep 2008 12:23:22 -0700 (PDT) Received: from ?80.222.42.69? ( [80.222.42.69]) by mx.google.com with ESMTPS id h6sm34729120nfh.21.2008.09.01.12.23.20 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 01 Sep 2008 12:23:21 -0700 (PDT) Message-ID: <48BC4127.30706@enterprisedb.com> Date: Mon, 01 Sep 2008 22:23:19 +0300 Organization: EnterpriseDB User-Agent: Mozilla-Thunderbird 2.0.0.14 (X11/20080509) MIME-Version: 1.0 To: Simon Riggs CC: List pgsql-patches Subject: Re: WIP Join Removal References: <1220176372.4371.118.camel@ebony.2ndQuadrant> In-Reply-To: <1220176372.4371.118.camel@ebony.2ndQuadrant> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit From: Heikki Linnakangas 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/3 X-Sequence-Number: 7018 Simon Riggs wrote: > Patch works, but there's a bit I haven't finished yet - checking unique > indexes. Did plan invalidation make it safe to rely on the presence of a unique index for planning decisions? Couldn't we also do join removal for inner joins, when there's a foreign key reference that enforces that there's one and only one matching tuple in the removed table: SELECT child.data FROM child, parent WHERE child.fkey = parent.pkey ? > + /* > + * We can now remove join by pulling up child plan from the keeprel. > + * This needs to be done considering costs, since its possible for > + * a nested inner indexscan plan to be cheaper. So it isn't > + * always desirable to remove the join. Can you elaborate that a bit? I can't imagine a case where we wouldn't want to remove a join, when we know we can. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com