Re: "failed to build any N-way joins" from a five-relation query

From: Tender Wang <tndrwang(at)gmail(dot)com>
To: Richard Guo <guofenglinux(at)gmail(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: "failed to build any N-way joins" from a five-relation query
Date: 2026-10-09 02:21:06
Message-ID: CAHewXNkOVjBWixJgmNsb_ZarvNkG0M6_s94fiArpQ4qLxFMgUA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Richard Guo <guofenglinux(at)gmail(dot)com> 于2026年10月8日周四 14:12写道:

> So I think we can fix it by teaching that search to also include any
> rel that laterally references a rel already in the set. Hench, the
> attached.
>

Thanks for the explanation and patch. I traced this through
join_is_legal() and now understand why the existing check misses the
dead end.
Starting with {t1, s2}, the outer-join search adds t2, but stops
because it does not follow the lateral dependency from t2 to s1.
Including s1 allows the next iteration to add t3, revealing the
conflict with the proposed join's lateral parameterization.

The fix makes sense to me.

--
Thanks,
Tender Wang

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Chao Li 2026-10-09 01:51:48 Re: Remove redundant MultiXactIdIsRunning() check in HeapTupleSatisfiesUpdate()