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

From Tender Wang
Subject Re: "failed to build any N-way joins" from a five-relation query
Date
Msg-id CAHewXNkOVjBWixJgmNsb_ZarvNkG0M6_s94fiArpQ4qLxFMgUA@mail.gmail.com
Whole thread
In response to "failed to build any N-way joins" from a five-relation query  (Richard Guo <guofenglinux@gmail.com>)
List pgsql-hackers
Richard Guo <guofenglinux@gmail.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



pgsql-hackers by date:

Previous
From: Chao Li
Date:
Subject: Re: Remove redundant MultiXactIdIsRunning() check in HeapTupleSatisfiesUpdate()
Next
From: "Hayato Kuroda (Fujitsu)"
Date:
Subject: RE: Incorrect CONTEXT reported for errors from parallel apply worker in logical replication