Re: pg_plan_advice fails when NestLoop outer side is Sort over FunctionScan

From: Andrei Lepikhov <lepihov(at)gmail(dot)com>
To: Lukas Fittl <lukas(at)fittl(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 20:56:42
Message-ID: 7093fa9e-6451-42f7-8956-4f9310545a89@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 4/4/26 20:52, Lukas Fittl wrote:
> Hi Andrei,
> 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.

My initial concern was about the design of the pg_plan_advice extension
in general. It seems flawed if it must follow the core plan-building
logic. Explore pg_hint_plan - their general concept is just to increase
the probability of a template subtree to maximum, not to assume that
some constructions are possible or not.

> Btw, is your extension available somewhere? That could help verify
> that the extension also works as expected with the fix.
This is the stage of core patch development. If the community rejects
the feature, I will convert it into an extension module (on request). -
It is too expensive to support each optimisation when you do it 'just
for fun'.

--
regards, Andrei Lepikhov,
pgEdge

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2026-04-05 11:39:01 BUG #19450: Where is checksum_block.inc.c after master install?
Previous Message Lukas Fittl 2026-04-04 18:52:04 Re: pg_plan_advice fails when NestLoop outer side is Sort over FunctionScan