From e35121ec2460081b38e32a8e64b953239cd872c4 Mon Sep 17 00:00:00 2001 From: TatsuyaKawata Date: Wed, 12 Aug 2026 12:23:54 +0900 Subject: [PATCH v1] Remove unused scan tuple slots from Sort, IncrementalSort, Material and Memoize These four nodes call ExecCreateScanSlotFromOuterPlan() during initialization, but none of them ever reads ss_ScanTupleSlot, nor the ps.scandesc / ps.scanops / ps.scanopsfixed / ps.scanopsset fields that ExecInitScanTupleSlot() sets as a side effect. This is unlike Agg, WindowAgg and Group, which do reuse ss_ScanTupleSlot as a working buffer for the current input tuple; those are left alone here. Also remove the line in MaterialState's header comment claiming that ss.ss_ScanTupleSlot refers to the output of the underlying plan. The identical wording in AggState's comment is still accurate and is kept. --- src/backend/executor/nodeIncrementalSort.c | 5 ----- src/backend/executor/nodeMaterial.c | 5 ----- src/backend/executor/nodeMemoize.c | 5 ----- src/backend/executor/nodeSort.c | 5 ----- src/include/nodes/execnodes.h | 2 -- 5 files changed, 22 deletions(-) diff --git a/src/backend/executor/nodeIncrementalSort.c b/src/backend/executor/nodeIncrementalSort.c index 1d831049b65..5e0e4ff8a31 100644 --- a/src/backend/executor/nodeIncrementalSort.c +++ b/src/backend/executor/nodeIncrementalSort.c @@ -1041,11 +1041,6 @@ ExecInitIncrementalSort(IncrementalSort *node, EState *estate, int eflags) */ outerPlanState(incrsortstate) = ExecInitNode(outerPlan(node), estate, eflags); - /* - * Initialize scan slot and type. - */ - ExecCreateScanSlotFromOuterPlan(estate, &incrsortstate->ss, &TTSOpsMinimalTuple); - /* * Initialize return slot and type. No need to initialize projection info * because we don't do any projections. diff --git a/src/backend/executor/nodeMaterial.c b/src/backend/executor/nodeMaterial.c index e5f387612bc..ea3a1efc235 100644 --- a/src/backend/executor/nodeMaterial.c +++ b/src/backend/executor/nodeMaterial.c @@ -225,11 +225,6 @@ ExecInitMaterial(Material *node, EState *estate, int eflags) ExecInitResultTupleSlotTL(&matstate->ss.ps, &TTSOpsMinimalTuple); matstate->ss.ps.ps_ProjInfo = NULL; - /* - * initialize tuple type. - */ - ExecCreateScanSlotFromOuterPlan(estate, &matstate->ss, &TTSOpsMinimalTuple); - return matstate; } diff --git a/src/backend/executor/nodeMemoize.c b/src/backend/executor/nodeMemoize.c index fdca97d7426..a24d2ef1924 100644 --- a/src/backend/executor/nodeMemoize.c +++ b/src/backend/executor/nodeMemoize.c @@ -982,11 +982,6 @@ ExecInitMemoize(Memoize *node, EState *estate, int eflags) ExecInitResultTupleSlotTL(&mstate->ss.ps, &TTSOpsMinimalTuple); mstate->ss.ps.ps_ProjInfo = NULL; - /* - * Initialize scan slot and type. - */ - ExecCreateScanSlotFromOuterPlan(estate, &mstate->ss, &TTSOpsMinimalTuple); - /* * Set the state machine to lookup the cache. We won't find anything * until we cache something, but this saves a special case to create the diff --git a/src/backend/executor/nodeSort.c b/src/backend/executor/nodeSort.c index e02313f7813..cbe03264730 100644 --- a/src/backend/executor/nodeSort.c +++ b/src/backend/executor/nodeSort.c @@ -264,11 +264,6 @@ ExecInitSort(Sort *node, EState *estate, int eflags) outerPlanState(sortstate) = ExecInitNode(outerPlan(node), estate, eflags); - /* - * Initialize scan slot and type. - */ - ExecCreateScanSlotFromOuterPlan(estate, &sortstate->ss, &TTSOpsVirtual); - /* * Initialize return slot and type. No need to initialize projection info * because this node doesn't do projections. diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index e95ac3eda35..44d0aefc876 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -2278,8 +2278,6 @@ typedef struct HashJoinState * * materialize nodes are used to materialize the results * of a subplan into a temporary file. - * - * ss.ss_ScanTupleSlot refers to output of underlying plan. * ---------------- */ typedef struct MaterialState -- 2.34.1