| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Richard Guo <guofenglinux(at)gmail(dot)com> |
| Cc: | francois(dot)jehl(at)pigment(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org, Robert Haas <robertmhaas(at)gmail(dot)com> |
| Subject: | Re: BUG #19460: FULL JOIN rewriting issue on empty queries |
| Date: | 2026-04-20 01:26:14 |
| Message-ID: | 81857.1776648374@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
Richard Guo <guofenglinux(at)gmail(dot)com> writes:
> On Mon, Apr 20, 2026 at 6:10 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> This turns out to be because somebody long ago thought that outer join
>> removal could be lazy about how much of the planner's data structures
>> it needs to update. Specifically, when the lower LEFT OUTER JOIN
>> gets removed, we failed to remove the associated relids from the
>> left_relids and right_relids of the upper "ON rhs.id = lhs.id" clause,
>> and that blocks recognition of the applicability of a hash or merge
>> join, because clause_sides_match_join() fails.
> I came to the same conclusion.
Thanks for looking at it! There is a loose end still bothering me:
if you remove the lower "WHERE t.id = ..." clause, or change it to be
something other than an equality constraint on t.id, the bug doesn't
manifest. The reason for that is un-obvious. I suppose it's somehow
related to the code that tries to push equality-to-a-constant through
outer join clauses, but that code shouldn't be able to produce any new
clauses here, so why is there a visible effect? I'm too tired to look
right now, and was planning to study it more tomorrow. But if you
are interested in digging before that, feel free.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Richard Guo | 2026-04-20 02:17:47 | Re: BUG #19460: FULL JOIN rewriting issue on empty queries |
| Previous Message | Richard Guo | 2026-04-20 01:12:11 | Re: BUG #19460: FULL JOIN rewriting issue on empty queries |