diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index 0c036209f0..aee81bd755 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -2397,10 +2397,13 @@ create_windowagg_plan(PlannerInfo *root, WindowAggPath *best_path) ListCell *lc; /* - * WindowAgg can project, so no need to be terribly picky about child - * tlist, but we do need grouping columns to be available + * Choice of tlist here is motivated by the fact that WindowAgg will be + * storing the input rows of window frames in a tuplestore; it therefore + * behooves us to request a small tlist to avoid wasting space. We do of + * course need grouping columns to be available. */ - subplan = create_plan_recurse(root, best_path->subpath, CP_LABEL_TLIST); + subplan = create_plan_recurse(root, best_path->subpath, + CP_LABEL_TLIST | CP_SMALL_TLIST); tlist = build_path_tlist(root, &best_path->path);