diff options
| author | Richard Guo | 2026-08-28 05:51:36 +0000 |
|---|---|---|
| committer | Richard Guo | 2026-08-28 06:05:35 +0000 |
| commit | 718f281672a91856f0d241aa5602d4d14f055a93 (patch) | |
| tree | 5530d8a289335061baddbb27dfcbe9fa7bda94fe | |
| parent | 7c503d683ca06d14052614ff39ec8648d1d722d0 (diff) | |
Propagate disabled_nodes to single-child Append paths
create_append_path() skips cost_append() when an Append has exactly
one child whose parallel awareness matches its own, since setrefs.c
strips such an Append out entirely. In that case it copies the
child's rowcount and costs directly, but it failed to copy
disabled_nodes. An Append over a disabled child therefore claimed to
contain no disabled nodes, letting a disabled path win over one that
is not disabled.
This is a regression in v18; before e22253467, disable_cost was folded
into a path's startup and total costs, so it rode along in the fields
this shortcut already copies.
Back-patch to v18. This can change plans in stable branches, but only
for installations that have explicitly disabled a node type, and only
to stop using the node they asked us to avoid.
Reported-by: Man Zeng <zengman@halodbtech.com>
Author: Tender Wang <tndrwang@gmail.com>
Reviewed-by: Richard Guo <guofenglinux@gmail.com>
Reviewed-by: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/CAHewXNm_Zx5EDoaD7wo7bq6cfRroNznS+RBCzT_p2-CWQXpgSw@mail.gmail.com
Backpatch-through: 18
| -rw-r--r-- | src/backend/optimizer/util/pathnode.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c index e8d8a537061..d76f69341f2 100644 --- a/src/backend/optimizer/util/pathnode.c +++ b/src/backend/optimizer/util/pathnode.c @@ -1392,9 +1392,9 @@ create_append_path(PlannerInfo *root, * child's pathkeys if any, overriding whatever the caller might've said. * Furthermore, if the child's parallel awareness matches the Append's, * then the Append is a no-op and will be discarded later (in setrefs.c). - * Then we can inherit the child's size and cost too, effectively charging - * zero for the Append. Otherwise, we must do the normal costsize - * calculation. + * Then we can inherit the child's size, cost and disabled-node count too, + * effectively charging zero for the Append. Otherwise, we must do the + * normal costsize calculation. */ if (list_length(pathnode->subpaths) == 1) { @@ -1403,6 +1403,7 @@ create_append_path(PlannerInfo *root, if (child->parallel_aware == parallel_aware) { pathnode->path.rows = child->rows; + pathnode->path.disabled_nodes = child->disabled_nodes; pathnode->path.startup_cost = child->startup_cost; pathnode->path.total_cost = child->total_cost; } |
