summaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeWindowAgg.c
diff options
context:
space:
mode:
authorAndres Freund2018-02-17 05:17:38 +0000
committerAndres Freund2018-02-17 05:17:38 +0000
commitad7dbee368a7cd9e595d2a957be784326b08c943 (patch)
treea4846e24bf9f2d78b7c8dfb04323ef984aede517 /src/backend/executor/nodeWindowAgg.c
parentbf6c614a2f2c58312b3be34a47e7fb7362e07bcb (diff)
Allow tupleslots to have a fixed tupledesc, use in executor nodes.
The reason for doing so is that it will allow expression evaluation to optimize based on the underlying tupledesc. In particular it will allow to JIT tuple deforming together with the expression itself. For that expression initialization needs to be moved after the relevant slots are initialized - mostly unproblematic, except in the case of nodeWorktablescan.c. After doing so there's no need for ExecAssignResultType() and ExecAssignResultTypeFromTL() anymore, as all former callers have been converted to create a slot with a fixed descriptor. When creating a slot with a fixed descriptor, tts_values/isnull can be allocated together with the main slot, reducing allocation overhead and increasing cache density a bit. Author: Andres Freund Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src/backend/executor/nodeWindowAgg.c')
-rw-r--r--src/backend/executor/nodeWindowAgg.c65
1 files changed, 24 insertions, 41 deletions
diff --git a/src/backend/executor/nodeWindowAgg.c b/src/backend/executor/nodeWindowAgg.c
index 1c807a82922..a56c3e89fd5 100644
--- a/src/backend/executor/nodeWindowAgg.c
+++ b/src/backend/executor/nodeWindowAgg.c
@@ -2288,30 +2288,6 @@ ExecInitWindowAgg(WindowAgg *node, EState *estate, int eflags)
ALLOCSET_DEFAULT_SIZES);
/*
- * tuple table initialization
- */
- ExecInitScanTupleSlot(estate, &winstate->ss);
- ExecInitResultTupleSlot(estate, &winstate->ss.ps);
- winstate->first_part_slot = ExecInitExtraTupleSlot(estate);
- winstate->agg_row_slot = ExecInitExtraTupleSlot(estate);
- winstate->temp_slot_1 = ExecInitExtraTupleSlot(estate);
- winstate->temp_slot_2 = ExecInitExtraTupleSlot(estate);
-
- /*
- * create frame head and tail slots only if needed (must match logic in
- * update_frameheadpos and update_frametailpos)
- */
- winstate->framehead_slot = winstate->frametail_slot = NULL;
-
- if (frameOptions & (FRAMEOPTION_RANGE | FRAMEOPTION_GROUPS))
- {
- if (!(frameOptions & FRAMEOPTION_START_UNBOUNDED_PRECEDING))
- winstate->framehead_slot = ExecInitExtraTupleSlot(estate);
- if (!(frameOptions & FRAMEOPTION_END_UNBOUNDED_FOLLOWING))
- winstate->frametail_slot = ExecInitExtraTupleSlot(estate);
- }
-
- /*
* WindowAgg nodes never have quals, since they can only occur at the
* logical top level of a query (ie, after any WHERE or HAVING filters)
*/
@@ -2328,28 +2304,35 @@ ExecInitWindowAgg(WindowAgg *node, EState *estate, int eflags)
* initialize source tuple type (which is also the tuple type that we'll
* store in the tuplestore and use in all our working slots).
*/
- ExecAssignScanTypeFromOuterPlan(&winstate->ss);
+ ExecCreateScanSlotFromOuterPlan(estate, &winstate->ss);
scanDesc = winstate->ss.ss_ScanTupleSlot->tts_tupleDescriptor;
- ExecSetSlotDescriptor(winstate->first_part_slot,
- winstate->ss.ss_ScanTupleSlot->tts_tupleDescriptor);
- ExecSetSlotDescriptor(winstate->agg_row_slot,
- winstate->ss.ss_ScanTupleSlot->tts_tupleDescriptor);
- ExecSetSlotDescriptor(winstate->temp_slot_1,
- winstate->ss.ss_ScanTupleSlot->tts_tupleDescriptor);
- ExecSetSlotDescriptor(winstate->temp_slot_2,
- winstate->ss.ss_ScanTupleSlot->tts_tupleDescriptor);
- if (winstate->framehead_slot)
- ExecSetSlotDescriptor(winstate->framehead_slot,
- winstate->ss.ss_ScanTupleSlot->tts_tupleDescriptor);
- if (winstate->frametail_slot)
- ExecSetSlotDescriptor(winstate->frametail_slot,
- winstate->ss.ss_ScanTupleSlot->tts_tupleDescriptor);
+ /*
+ * tuple table initialization
+ */
+ winstate->first_part_slot = ExecInitExtraTupleSlot(estate, scanDesc);
+ winstate->agg_row_slot = ExecInitExtraTupleSlot(estate, scanDesc);
+ winstate->temp_slot_1 = ExecInitExtraTupleSlot(estate, scanDesc);
+ winstate->temp_slot_2 = ExecInitExtraTupleSlot(estate, scanDesc);
+
+ /*
+ * create frame head and tail slots only if needed (must match logic in
+ * update_frameheadpos and update_frametailpos)
+ */
+ winstate->framehead_slot = winstate->frametail_slot = NULL;
+
+ if (frameOptions & (FRAMEOPTION_RANGE | FRAMEOPTION_GROUPS))
+ {
+ if (!(frameOptions & FRAMEOPTION_START_UNBOUNDED_PRECEDING))
+ winstate->framehead_slot = ExecInitExtraTupleSlot(estate, scanDesc);
+ if (!(frameOptions & FRAMEOPTION_END_UNBOUNDED_FOLLOWING))
+ winstate->frametail_slot = ExecInitExtraTupleSlot(estate, scanDesc);
+ }
/*
- * Initialize result tuple type and projection info.
+ * Initialize result slot, type and projection.
*/
- ExecAssignResultTypeFromTL(&winstate->ss.ps);
+ ExecInitResultTupleSlotTL(estate, &winstate->ss.ps);
ExecAssignProjectionInfo(&winstate->ss.ps, NULL);
/* Set up data for comparing tuples */