Re: Join removal and attr_needed cleanup

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bennie Swart <bennieswart(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Join removal and attr_needed cleanup
Date: 2024-11-10 16:17:42
Message-ID: 94515.1731255462@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Bennie Swart <bennieswart(at)gmail(dot)com> writes:
> -- join elimination fails
> -- expect both b and c to be eliminated, but b remains
> explain (costs off)
>   select a.*
>     from foo a
>       left join foo b on (b.id1, b.id2) = (a.id1, a.id2)
>       left join foo c on (c.id1, c.id2) = (a.id1, b.id2);
>                                        -- ^^^^^^^^^^^^^^

This does work in HEAD, presumably as a consequence of a3179ab69:

regression=# explain (costs off)
select a.*
from foo a
left join foo b on (b.id1, b.id2) = (a.id1, a.id2)
left join foo c on (c.id1, c.id2) = (a.id1, b.id2);
QUERY PLAN
-------------------
Seq Scan on foo a
(1 row)

I think it's still too soon to consider back-patching that though,
since it's only been in the tree for six weeks.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2024-11-10 16:19:09 Re: proposal: schema variables
Previous Message Tom Lane 2024-11-10 15:46:48 Re: [BUG] Fix DETACH with FK pointing to a partitioned table fails