pgsql: pg_plan_advice: Avoid miscategorizing partitionwise scans as ord

From: Robert Haas <rhaas(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: pg_plan_advice: Avoid miscategorizing partitionwise scans as ord
Date: 2026-10-08 17:00:23
Message-ID: E1xErTj-00000000pxN-054H@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

pg_plan_advice: Avoid miscategorizing partitionwise scans as ordinary.

Given an Append or MergeAppend node, pgpa_build_scan needs to call
pgpa_make_scan for the node's own apprelids, and also for each element
of child_append_relid_sets. It did that, but it overlooked the fact
that the scan type applicable to the child scans might differ from
the scan type applicable to the parent scan. The problem can only
occur in one direction: an RTE_SUBQUERY (Merge)Append can appear on
top of a RTE_RELATION (Merge)Append, but not the reverse, so the
only failure mode here is to classify a partitionwise scan of a child
appendrel as PGPA_SCAN_ORDINARY rather than PGPA_SCAN_PARTITIONWISE,
leading to failure to include PARTITIONWISE(something) in the
generated advice string.

Backpatch-through: 19
Discussion: http://postgr.es/m/CA+TgmoYYHC4i-Gpzc9-JYHqih6pOK+6LTYFiNR-PioXG1nKkOQ@mail.gmail.com

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/afadfb3496edc40fb0988edc72df2e23b178d1a0

Modified Files
--------------
contrib/pg_plan_advice/expected/partitionwise.out | 52 +++++++++++++++++++++++
contrib/pg_plan_advice/pgpa_scan.c | 9 +++-
contrib/pg_plan_advice/sql/partitionwise.sql | 23 ++++++++++
3 files changed, 82 insertions(+), 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Masahiko Sawada 2026-10-08 17:33:47 pgsql: Stabilize recently added tests in 051_effective_wal_level.pl.
Previous Message Robert Haas 2026-10-08 16:24:49 pgsql: Fix failure of setrefs.c to process child_append_relid_sets