Change the IndexScanInstrumentation fields in IndexScanState,
IndexOnlyScanState, and BitmapIndexScanState from inline structs to
pointers. This avoids additional space overhead whenever new fields are
added to IndexScanInstrumentation in the future, at least in the common
case where the instrumentation isn't used (i.e. when the executor node
isn't being run through an EXPLAIN ANALYZE).
Preparation for an upcoming patch series that will add index
prefetching. The new slot-based interface that will enable index
prefetching necessitates that we add at least one more field to
IndexScanInstrumentation (to count heap fetches during index-only
scans).
Author: Peter Geoghegan <pg@bowt.ie>
Reviewed-By: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CAH2-Wz=g=JTSyDB4UtB5su2ZcvsS7VbP+ZMvvaG6ABoCb+s8Lw@mail.gmail.com
{
IndexScanState *indexstate = ((IndexScanState *) planstate);
{
IndexScanState *indexstate = ((IndexScanState *) planstate);
- nsearches = indexstate->iss_Instrument.nsearches;
+ nsearches = indexstate->iss_Instrument->nsearches;
SharedInfo = indexstate->iss_SharedInfo;
break;
}
SharedInfo = indexstate->iss_SharedInfo;
break;
}
{
IndexOnlyScanState *indexstate = ((IndexOnlyScanState *) planstate);
{
IndexOnlyScanState *indexstate = ((IndexOnlyScanState *) planstate);
- nsearches = indexstate->ioss_Instrument.nsearches;
+ nsearches = indexstate->ioss_Instrument->nsearches;
SharedInfo = indexstate->ioss_SharedInfo;
break;
}
SharedInfo = indexstate->ioss_SharedInfo;
break;
}
{
BitmapIndexScanState *indexstate = ((BitmapIndexScanState *) planstate);
{
BitmapIndexScanState *indexstate = ((BitmapIndexScanState *) planstate);
- nsearches = indexstate->biss_Instrument.nsearches;
+ nsearches = indexstate->biss_Instrument->nsearches;
SharedInfo = indexstate->biss_SharedInfo;
break;
}
SharedInfo = indexstate->biss_SharedInfo;
break;
}
* shutdown on the workers. On rescan it will spin up new workers
* which will have a new BitmapIndexScanState and zeroed stats.
*/
* shutdown on the workers. On rescan it will spin up new workers
* which will have a new BitmapIndexScanState and zeroed stats.
*/
- winstrument->nsearches += node->biss_Instrument.nsearches;
+ winstrument->nsearches += node->biss_Instrument->nsearches;
if (eflags & EXEC_FLAG_EXPLAIN_ONLY)
return indexstate;
if (eflags & EXEC_FLAG_EXPLAIN_ONLY)
return indexstate;
+ /* Set up instrumentation of bitmap index scans if requested */
+ if (estate->es_instrument)
+ indexstate->biss_Instrument = palloc0_object(IndexScanInstrumentation);
+
/* Open the index relation. */
lockmode = exec_rt_fetch(node->scan.scanrelid, estate)->rellockmode;
indexstate->biss_RelationDesc = index_open(node->indexid, lockmode);
/* Open the index relation. */
lockmode = exec_rt_fetch(node->scan.scanrelid, estate)->rellockmode;
indexstate->biss_RelationDesc = index_open(node->indexid, lockmode);
indexstate->biss_ScanDesc =
index_beginscan_bitmap(indexstate->biss_RelationDesc,
estate->es_snapshot,
indexstate->biss_ScanDesc =
index_beginscan_bitmap(indexstate->biss_RelationDesc,
estate->es_snapshot,
- &indexstate->biss_Instrument,
+ indexstate->biss_Instrument,
indexstate->biss_NumScanKeys);
/*
indexstate->biss_NumScanKeys);
/*
scandesc = index_beginscan(node->ss.ss_currentRelation,
node->ioss_RelationDesc,
estate->es_snapshot,
scandesc = index_beginscan(node->ss.ss_currentRelation,
node->ioss_RelationDesc,
estate->es_snapshot,
- &node->ioss_Instrument,
node->ioss_NumScanKeys,
node->ioss_NumOrderByKeys);
node->ioss_NumScanKeys,
node->ioss_NumOrderByKeys);
* shutdown on the workers. On rescan it will spin up new workers
* which will have a new IndexOnlyScanState and zeroed stats.
*/
* shutdown on the workers. On rescan it will spin up new workers
* which will have a new IndexOnlyScanState and zeroed stats.
*/
- winstrument->nsearches += node->ioss_Instrument.nsearches;
+ winstrument->nsearches += node->ioss_Instrument->nsearches;
if (eflags & EXEC_FLAG_EXPLAIN_ONLY)
return indexstate;
if (eflags & EXEC_FLAG_EXPLAIN_ONLY)
return indexstate;
+ /* Set up instrumentation of index-only scans if requested */
+ if (estate->es_instrument)
+ indexstate->ioss_Instrument = palloc0_object(IndexScanInstrumentation);
+
/* Open the index relation. */
lockmode = exec_rt_fetch(node->scan.scanrelid, estate)->rellockmode;
indexRelation = index_open(node->indexid, lockmode);
/* Open the index relation. */
lockmode = exec_rt_fetch(node->scan.scanrelid, estate)->rellockmode;
indexRelation = index_open(node->indexid, lockmode);
node->ioss_ScanDesc =
index_beginscan_parallel(node->ss.ss_currentRelation,
node->ioss_RelationDesc,
node->ioss_ScanDesc =
index_beginscan_parallel(node->ss.ss_currentRelation,
node->ioss_RelationDesc,
- &node->ioss_Instrument,
node->ioss_NumScanKeys,
node->ioss_NumOrderByKeys,
piscan);
node->ioss_NumScanKeys,
node->ioss_NumOrderByKeys,
piscan);
node->ioss_ScanDesc =
index_beginscan_parallel(node->ss.ss_currentRelation,
node->ioss_RelationDesc,
node->ioss_ScanDesc =
index_beginscan_parallel(node->ss.ss_currentRelation,
node->ioss_RelationDesc,
- &node->ioss_Instrument,
node->ioss_NumScanKeys,
node->ioss_NumOrderByKeys,
piscan);
node->ioss_NumScanKeys,
node->ioss_NumOrderByKeys,
piscan);
scandesc = index_beginscan(node->ss.ss_currentRelation,
node->iss_RelationDesc,
estate->es_snapshot,
scandesc = index_beginscan(node->ss.ss_currentRelation,
node->iss_RelationDesc,
estate->es_snapshot,
node->iss_NumScanKeys,
node->iss_NumOrderByKeys);
node->iss_NumScanKeys,
node->iss_NumOrderByKeys);
scandesc = index_beginscan(node->ss.ss_currentRelation,
node->iss_RelationDesc,
estate->es_snapshot,
scandesc = index_beginscan(node->ss.ss_currentRelation,
node->iss_RelationDesc,
estate->es_snapshot,
node->iss_NumScanKeys,
node->iss_NumOrderByKeys);
node->iss_NumScanKeys,
node->iss_NumOrderByKeys);
* shutdown on the workers. On rescan it will spin up new workers
* which will have a new IndexOnlyScanState and zeroed stats.
*/
* shutdown on the workers. On rescan it will spin up new workers
* which will have a new IndexOnlyScanState and zeroed stats.
*/
- winstrument->nsearches += node->iss_Instrument.nsearches;
+ winstrument->nsearches += node->iss_Instrument->nsearches;
if (eflags & EXEC_FLAG_EXPLAIN_ONLY)
return indexstate;
if (eflags & EXEC_FLAG_EXPLAIN_ONLY)
return indexstate;
+ /* Set up instrumentation of index scans if requested */
+ if (estate->es_instrument)
+ indexstate->iss_Instrument = palloc0_object(IndexScanInstrumentation);
+
/* Open the index relation. */
lockmode = exec_rt_fetch(node->scan.scanrelid, estate)->rellockmode;
indexstate->iss_RelationDesc = index_open(node->indexid, lockmode);
/* Open the index relation. */
lockmode = exec_rt_fetch(node->scan.scanrelid, estate)->rellockmode;
indexstate->iss_RelationDesc = index_open(node->indexid, lockmode);
node->iss_ScanDesc =
index_beginscan_parallel(node->ss.ss_currentRelation,
node->iss_RelationDesc,
node->iss_ScanDesc =
index_beginscan_parallel(node->ss.ss_currentRelation,
node->iss_RelationDesc,
node->iss_NumScanKeys,
node->iss_NumOrderByKeys,
piscan);
node->iss_NumScanKeys,
node->iss_NumOrderByKeys,
piscan);
node->iss_ScanDesc =
index_beginscan_parallel(node->ss.ss_currentRelation,
node->iss_RelationDesc,
node->iss_ScanDesc =
index_beginscan_parallel(node->ss.ss_currentRelation,
node->iss_RelationDesc,
node->iss_NumScanKeys,
node->iss_NumOrderByKeys,
piscan);
node->iss_NumScanKeys,
node->iss_NumOrderByKeys,
piscan);
ExprContext *iss_RuntimeContext;
Relation iss_RelationDesc;
struct IndexScanDescData *iss_ScanDesc;
ExprContext *iss_RuntimeContext;
Relation iss_RelationDesc;
struct IndexScanDescData *iss_ScanDesc;
- IndexScanInstrumentation iss_Instrument;
+ IndexScanInstrumentation *iss_Instrument;
SharedIndexScanInstrumentation *iss_SharedInfo;
/* These are needed for re-checking ORDER BY expr ordering */
SharedIndexScanInstrumentation *iss_SharedInfo;
/* These are needed for re-checking ORDER BY expr ordering */
ExprContext *ioss_RuntimeContext;
Relation ioss_RelationDesc;
struct IndexScanDescData *ioss_ScanDesc;
ExprContext *ioss_RuntimeContext;
Relation ioss_RelationDesc;
struct IndexScanDescData *ioss_ScanDesc;
- IndexScanInstrumentation ioss_Instrument;
+ IndexScanInstrumentation *ioss_Instrument;
SharedIndexScanInstrumentation *ioss_SharedInfo;
TupleTableSlot *ioss_TableSlot;
Buffer ioss_VMBuffer;
SharedIndexScanInstrumentation *ioss_SharedInfo;
TupleTableSlot *ioss_TableSlot;
Buffer ioss_VMBuffer;
ExprContext *biss_RuntimeContext;
Relation biss_RelationDesc;
struct IndexScanDescData *biss_ScanDesc;
ExprContext *biss_RuntimeContext;
Relation biss_RelationDesc;
struct IndexScanDescData *biss_ScanDesc;
- IndexScanInstrumentation biss_Instrument;
+ IndexScanInstrumentation *biss_Instrument;
SharedIndexScanInstrumentation *biss_SharedInfo;
} BitmapIndexScanState;
SharedIndexScanInstrumentation *biss_SharedInfo;
} BitmapIndexScanState;