aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeBitmapHeapscan.c
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2018-02-16 21:17:38 -0800
committerAndres Freund <andres@anarazel.de>2018-02-16 21:17:38 -0800
commitad7dbee368a7cd9e595d2a957be784326b08c943 (patch)
treea4846e24bf9f2d78b7c8dfb04323ef984aede517 /src/backend/executor/nodeBitmapHeapscan.c
parentbf6c614a2f2c58312b3be34a47e7fb7362e07bcb (diff)
downloadpostgresql-ad7dbee368a7cd9e595d2a957be784326b08c943.tar.gz
postgresql-ad7dbee368a7cd9e595d2a957be784326b08c943.zip
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/20171206093717.vqdxe5icqttpxs3p@alap3.anarazel.de
Diffstat (limited to 'src/backend/executor/nodeBitmapHeapscan.c')
-rw-r--r--src/backend/executor/nodeBitmapHeapscan.c56
1 files changed, 26 insertions, 30 deletions
diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index fa65d4efbe7..3e1c9e07145 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -907,23 +907,39 @@ ExecInitBitmapHeapScan(BitmapHeapScan *node, EState *estate, int eflags)
ExecAssignExprContext(estate, &scanstate->ss.ps);
/*
- * initialize child expressions
+ * open the base relation and acquire appropriate lock on it.
*/
- scanstate->ss.ps.qual =
- ExecInitQual(node->scan.plan.qual, (PlanState *) scanstate);
- scanstate->bitmapqualorig =
- ExecInitQual(node->bitmapqualorig, (PlanState *) scanstate);
+ currentRelation = ExecOpenScanRelation(estate, node->scan.scanrelid, eflags);
+
+ /*
+ * initialize child nodes
+ *
+ * We do this after ExecOpenScanRelation because the child nodes will open
+ * indexscans on our relation's indexes, and we want to be sure we have
+ * acquired a lock on the relation first.
+ */
+ outerPlanState(scanstate) = ExecInitNode(outerPlan(node), estate, eflags);
/*
- * tuple table initialization
+ * get the scan type from the relation descriptor.
*/
- ExecInitResultTupleSlot(estate, &scanstate->ss.ps);
- ExecInitScanTupleSlot(estate, &scanstate->ss);
+ ExecInitScanTupleSlot(estate, &scanstate->ss,
+ RelationGetDescr(currentRelation));
+
/*
- * open the base relation and acquire appropriate lock on it.
+ * Initialize result slot, type and projection.
*/
- currentRelation = ExecOpenScanRelation(estate, node->scan.scanrelid, eflags);
+ ExecInitResultTupleSlotTL(estate, &scanstate->ss.ps);
+ ExecAssignScanProjectionInfo(&scanstate->ss);
+
+ /*
+ * initialize child expressions
+ */
+ scanstate->ss.ps.qual =
+ ExecInitQual(node->scan.plan.qual, (PlanState *) scanstate);
+ scanstate->bitmapqualorig =
+ ExecInitQual(node->bitmapqualorig, (PlanState *) scanstate);
/*
* Determine the maximum for prefetch_target. If the tablespace has a
@@ -953,26 +969,6 @@ ExecInitBitmapHeapScan(BitmapHeapScan *node, EState *estate, int eflags)
NULL);
/*
- * get the scan type from the relation descriptor.
- */
- ExecAssignScanType(&scanstate->ss, RelationGetDescr(currentRelation));
-
- /*
- * Initialize result tuple type and projection info.
- */
- ExecAssignResultTypeFromTL(&scanstate->ss.ps);
- ExecAssignScanProjectionInfo(&scanstate->ss);
-
- /*
- * initialize child nodes
- *
- * We do this last because the child nodes will open indexscans on our
- * relation's indexes, and we want to be sure we have acquired a lock on
- * the relation first.
- */
- outerPlanState(scanstate) = ExecInitNode(outerPlan(node), estate, eflags);
-
- /*
* all done.
*/
return scanstate;