From 6bb0c3417cd8877fc9db50b9acaf8e2fed6e1d79 Mon Sep 17 00:00:00 2001 From: Richard Guo Date: Thu, 27 Aug 2026 16:09:55 +0900 Subject: [PATCH v2] 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 v17; 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. As with the similar oversights fixed by 47c110f77 and 6e466e1e8, though, no back-patch, since planner fixes risk destabilizing plans in stable branches and the consequences here aren't severe enough to justify an exception. Reported-by: Man Zeng Author: Tender Wang Reviewed-by: Richard Guo Discussion: https://postgr.es/m/CAHewXNm_Zx5EDoaD7wo7bq6cfRroNznS+RBCzT_p2-CWQXpgSw@mail.gmail.com --- src/backend/optimizer/util/pathnode.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c index a8dcad72958..2ba31765ca5 100644 --- a/src/backend/optimizer/util/pathnode.c +++ b/src/backend/optimizer/util/pathnode.c @@ -1442,9 +1442,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) { @@ -1453,6 +1453,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; } -- 2.37.1 (Apple Git-137.1)