On Wed, Sep 9, 2026 at 4:16 PM Robert Haas <robertmhaas@gmail.com> wrote:
> Generally, all of these problems stem from advice
> enforcement (which tries to make the plan obey the advice) being out
> of step with advice feedback (which says whether the plan actually did
> obey the advice).
AI found another case and prepared the attached patch. A single-target
PARTITIONWISE entry on a plain table disables every scan path,
although the advice only says that the table must not participate in a
partitionwise join.
load 'pg_plan_advice';
create table plain (i int);
set pg_plan_advice.advice = 'PARTITIONWISE(plain)';
explain (costs off, plan_advice) select * from plain;
This produces:
Seq Scan on plain
Disabled: true
Supplied Plan Advice:
PARTITIONWISE(plain) /* matched, failed */
pgpa_planner_apply_scan_advice() treats this single-target PARTITIONWISE
entry as an Append/MergeAppend scan restriction. For the plain table,
that clears all available scan methods. The feedback walker then
looks for a partitionwise scan and reports failure.
The patch uses the preprocessed RTE inheritance flag to treat this as a
matched no-op. It also handles the equivalent PARTITIONWISE((plain)) form.
This is on REL_19_STABLE at b73d13c3, and the patch applies cleanly to
master at 374522aa.
I have not manually reviewed the C changes. The pg_plan_advice regression
suite, its foreign-scan TAP test, and the test_plan_advice TAP test pass.
Nik