Re: WIP Join Removal

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Simon Riggs <simon(at)2ndQuadrant(dot)com>
Cc: List pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: WIP Join Removal
Date: 2008-09-02 10:20:36
Message-ID: 48BD1374.4030504@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Simon Riggs wrote:
> It turns out that a join like this
>
> select a.col2
> from a left outer join b on a.col1 = b.col1
> where b.col2 = 1;
>
> can be cheaper if we don't remove the join, when there is an index on
> a.col1 and b.col2, because the presence of b allows the values returned
> from b to be used for an index scan on a.

Umm, you *can't* remove that join. Because of the condition "b.col2 =
1", which implies that "b.col1 IS NOT NULL", that's actually equal to:

select a.col2
from a inner join b on a.col1 = b.col1
where b.col2 = 1;

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Heikki Linnakangas 2008-09-02 10:38:20 Re: rmgr hooks and contrib/rmgr_hook
Previous Message Simon Riggs 2008-09-02 09:49:40 Re: rmgr hooks and contrib/rmgr_hook