| From: | Richard Guo <guofenglinux(at)gmail(dot)com> |
|---|---|
| To: | Tender Wang <tndrwang(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-10 10:49:25 |
| Message-ID: | CAMbWs48PtLfUUv67C+x572imDFdZvY-eFHOwGYue1L2Q2ZOtog@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Sat, Oct 10, 2026 at 11:37 AM Tender Wang <tndrwang(at)gmail(dot)com> wrote:
> The FULL JOIN is planned as a separate joinlist subproblem, and its
> resulting joinrel becomes an input to the outer join search.
> The loop over simple_rel_array does not account for this composite
> input's lateral dependencies.
Thanks for the report and the analysis. I agree that this is the key
point: the full join's joinrel is a single input to the outer join
search, so once s1 has to be included in the search, t3 has to come
along with it.
It is not specific to full joins, though. join_collapse_limit or
from_collapse_limit can also make sub-joinlist joinrels.
> The proposed fix is to also scan joinrel entries in root->initial_rels
> when expanding join_plus_rhs:
+1 to this idea, and I think we can take it one step further.
root->initial_rels contains all the inputs of the current join search,
base rels as well as sub-joinlist joinrels, so a single loop over it
can replace the loop over simple_rel_array in v1. For each input that
laterally references a rel found so far, we add all of its relids.
Hence, the attached v2.
- Richard
| Attachment | Content-Type | Size |
|---|---|---|
| v2-0001-Disallow-joins-whose-lateral-references-can-never.patch | application/octet-stream | 10.6 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | ZizhuanLiu X-MAN | 2026-10-10 10:54:56 | Re: examine_variable ignored CollateExpr |
| Previous Message | Srinath Reddy Sadipiralla | 2026-10-10 10:44:52 | [RFC PATCH v1] On-demand WAL replay: accept connections before crash recovery has applied the WAL |