Re: BUG #18953: Planner fails to build plan for complex query with LATERAL references

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: exclusion(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18953: Planner fails to build plan for complex query with LATERAL references
Date: 2025-06-11 13:28:23
Message-ID: CAMbWs4_=9CbTSVLa+R+xcdo2dVZq79aDpHQcO6uzEO0uiUc8Sg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, Jun 11, 2025 at 5:33 PM Richard Guo <guofenglinux(at)gmail(dot)com> wrote:
> In this query, the join between t3 and s is placed into a separate
> join sub-problem due to the from_collapse_limit. This join is deemed
> not legal by join_is_legal(), as have_dangerous_phv() thinks the PHV
> could pose a hazard as described in that function's comment. As a
> result, no join could be built for this sub-problem.

> No idea how to fix this though. Any thoughts?

This might be a silly idea, but if we can't find a valid plan for a
join sub-problem, perhaps we could consider flattening the
sub-joinlist into the higher level to explore a solution in a broader
search space. The top-most joinlist should always be able to produce
a valid plan, otherwise something must be wrong during planning.

This may violate the from_collapse_limit restriction, but such cases
are expected to be very rare.

Thanks
Richard

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Anthonin Bonnefoy 2025-06-11 14:11:14 Re: BUG #18944: Assertion Failure in psql with idle_session_timeout Set
Previous Message PG Bug reporting form 2025-06-11 12:34:48 BUG #18955: pg_ctl output not being logged in stderr log on Windows if started with "net start"