mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
Instrument index-only scans to count heap fetches performed.
Patch by me; review by Tom Lane, Jeff Davis, and Peter Geoghegan.
This commit is contained in:
@ -1012,6 +1012,9 @@ ExplainNode(PlanState *planstate, List *ancestors,
|
|||||||
if (plan->qual)
|
if (plan->qual)
|
||||||
show_instrumentation_count("Rows Removed by Filter", 1,
|
show_instrumentation_count("Rows Removed by Filter", 1,
|
||||||
planstate, es);
|
planstate, es);
|
||||||
|
if (es->analyze)
|
||||||
|
ExplainPropertyLong("Heap Fetches",
|
||||||
|
((IndexOnlyScanState *) planstate)->ioss_HeapFetches, es);
|
||||||
break;
|
break;
|
||||||
case T_BitmapIndexScan:
|
case T_BitmapIndexScan:
|
||||||
show_scan_qual(((BitmapIndexScan *) plan)->indexqualorig,
|
show_scan_qual(((BitmapIndexScan *) plan)->indexqualorig,
|
||||||
|
@ -90,6 +90,7 @@ IndexOnlyNext(IndexOnlyScanState *node)
|
|||||||
/*
|
/*
|
||||||
* Rats, we have to visit the heap to check visibility.
|
* Rats, we have to visit the heap to check visibility.
|
||||||
*/
|
*/
|
||||||
|
node->ioss_HeapFetches++;
|
||||||
tuple = index_fetch_heap(scandesc);
|
tuple = index_fetch_heap(scandesc);
|
||||||
if (tuple == NULL)
|
if (tuple == NULL)
|
||||||
continue; /* no visible tuple, try next index entry */
|
continue; /* no visible tuple, try next index entry */
|
||||||
@ -346,6 +347,7 @@ ExecInitIndexOnlyScan(IndexOnlyScan *node, EState *estate, int eflags)
|
|||||||
indexstate = makeNode(IndexOnlyScanState);
|
indexstate = makeNode(IndexOnlyScanState);
|
||||||
indexstate->ss.ps.plan = (Plan *) node;
|
indexstate->ss.ps.plan = (Plan *) node;
|
||||||
indexstate->ss.ps.state = estate;
|
indexstate->ss.ps.state = estate;
|
||||||
|
indexstate->ioss_HeapFetches = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Miscellaneous initialization
|
* Miscellaneous initialization
|
||||||
|
@ -1260,6 +1260,7 @@ typedef struct IndexScanState
|
|||||||
* RelationDesc index relation descriptor
|
* RelationDesc index relation descriptor
|
||||||
* ScanDesc index scan descriptor
|
* ScanDesc index scan descriptor
|
||||||
* VMBuffer buffer in use for visibility map testing, if any
|
* VMBuffer buffer in use for visibility map testing, if any
|
||||||
|
* HeapFetches number of tuples we were forced to fetch from heap
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
typedef struct IndexOnlyScanState
|
typedef struct IndexOnlyScanState
|
||||||
@ -1277,6 +1278,7 @@ typedef struct IndexOnlyScanState
|
|||||||
Relation ioss_RelationDesc;
|
Relation ioss_RelationDesc;
|
||||||
IndexScanDesc ioss_ScanDesc;
|
IndexScanDesc ioss_ScanDesc;
|
||||||
Buffer ioss_VMBuffer;
|
Buffer ioss_VMBuffer;
|
||||||
|
long ioss_HeapFetches;
|
||||||
} IndexOnlyScanState;
|
} IndexOnlyScanState;
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
|
Reference in New Issue
Block a user