Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9f9135d

Browse files
committed
Instrument index-only scans to count heap fetches performed.
Patch by me; review by Tom Lane, Jeff Davis, and Peter Geoghegan.
1 parent0814677 commit9f9135d

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

‎src/backend/commands/explain.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,9 @@ ExplainNode(PlanState *planstate, List *ancestors,
10121012
if (plan->qual)
10131013
show_instrumentation_count("Rows Removed by Filter",1,
10141014
planstate,es);
1015+
if (es->analyze)
1016+
ExplainPropertyLong("Heap Fetches",
1017+
((IndexOnlyScanState*)planstate)->ioss_HeapFetches,es);
10151018
break;
10161019
caseT_BitmapIndexScan:
10171020
show_scan_qual(((BitmapIndexScan*)plan)->indexqualorig,

‎src/backend/executor/nodeIndexonlyscan.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ IndexOnlyNext(IndexOnlyScanState *node)
9090
/*
9191
* Rats, we have to visit the heap to check visibility.
9292
*/
93+
node->ioss_HeapFetches++;
9394
tuple=index_fetch_heap(scandesc);
9495
if (tuple==NULL)
9596
continue;/* no visible tuple, try next index entry */
@@ -346,6 +347,7 @@ ExecInitIndexOnlyScan(IndexOnlyScan *node, EState *estate, int eflags)
346347
indexstate=makeNode(IndexOnlyScanState);
347348
indexstate->ss.ps.plan= (Plan*)node;
348349
indexstate->ss.ps.state=estate;
350+
indexstate->ioss_HeapFetches=0;
349351

350352
/*
351353
* Miscellaneous initialization

‎src/include/nodes/execnodes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,6 +1260,7 @@ typedef struct IndexScanState
12601260
*RelationDesc index relation descriptor
12611261
*ScanDesc index scan descriptor
12621262
*VMBuffer buffer in use for visibility map testing, if any
1263+
*HeapFetches number of tuples we were forced to fetch from heap
12631264
* ----------------
12641265
*/
12651266
typedefstructIndexOnlyScanState
@@ -1277,6 +1278,7 @@ typedef struct IndexOnlyScanState
12771278
Relationioss_RelationDesc;
12781279
IndexScanDescioss_ScanDesc;
12791280
Bufferioss_VMBuffer;
1281+
longioss_HeapFetches;
12801282
}IndexOnlyScanState;
12811283

12821284
/* ----------------

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp