| From: | Lukas Fittl <lukas(at)fittl(dot)com> |
|---|---|
| To: | Andrei Lepikhov <lepihov(at)gmail(dot)com> |
| Cc: | pgsql-bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com> |
| Subject: | Re: pg_plan_advice fails when NestLoop outer side is Sort over FunctionScan |
| Date: | 2026-04-04 18:52:04 |
| Message-ID: | CAP53Pkw2Lw0bavkCR-ygmaGACBjwmY3Voq0Yhwo9rVOBWxQuyw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
Hi Andrei,
On Fri, Apr 3, 2026 at 12:17 AM Andrei Lepikhov <lepihov(at)gmail(dot)com> wrote:
>
> Hi,
>
> While testing the optimiser extension that extends planner's scope by
> pre-sorted outer paths I found that current master hit a crash in the
> test_plan_advice TAP test
> (src/test/modules/test_plan_advice/t/001_replan_regress.pl):
>
> ERROR: plan node has no RTIs: 380
Thanks for the bug report and reproducer!
it seems to me this is caused by the join analysis tree walker in
pgpa_join.c / pgpa_decompose_join being a bit too specific to what the
core planner will produce, i.e. it only assumes Merge Joins will have
Sort nodes directly underneath them.
I personally don't see harm in broadening the logic here to support
Nested Loop Joins and Hash Joins as well.
See attached a patch that addresses this, and passes cleanly for me on
a modified version of your branch [0].
Btw, is your extension available somewhere? That could help verify
that the extension also works as expected with the fix.
Thanks,
Lukas
[0]: https://github.com/lfittl/postgres/tree/bounded-left-join-outer-with-fix
--
Lukas Fittl
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-pg_plan_advice-Skip-Sort-nodes-under-all-join-typ.patch | application/x-patch | 2.6 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andrei Lepikhov | 2026-04-04 20:56:42 | Re: pg_plan_advice fails when NestLoop outer side is Sort over FunctionScan |
| Previous Message | Tom Lane | 2026-04-04 16:41:41 | Re: array_agg(anyarray) silently produces corrupt results with parallel workers when inputs mix NULL and non-NULL array elements |