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

Commit15a8f8c

Browse files
committed
Fix IndexOnlyScan counter for heap fetches in parallel mode
The HeapFetches counter was using a simple value in IndexOnlyScanState,which fails to propagate values from parallel workers; so the counts arewrong when IndexOnlyScan runs in parallel. Move it to Instrumentation,like all the other counters.While at it, change INSERT ON CONFLICT conflicting tuple counter to usethe new ntuples2 instead of nfiltered2, which is a blatant misuse.Discussion:https://postgr.es/m/20180409215851.idwc75ct2bzi6tea@alvherre.pgsql
1 parent1a40485 commit15a8f8c

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

‎src/backend/commands/explain.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,12 +1459,8 @@ ExplainNode(PlanState *planstate, List *ancestors,
14591459
show_instrumentation_count("Rows Removed by Filter",1,
14601460
planstate,es);
14611461
if (es->analyze)
1462-
{
1463-
longheapFetches=
1464-
((IndexOnlyScanState*)planstate)->ioss_HeapFetches;
1465-
1466-
ExplainPropertyInteger("Heap Fetches",NULL,heapFetches,es);
1467-
}
1462+
ExplainPropertyFloat("Heap Fetches",NULL,
1463+
planstate->instrument->ntuples2,0,es);
14681464
break;
14691465
caseT_BitmapIndexScan:
14701466
show_scan_qual(((BitmapIndexScan*)plan)->indexqualorig,
@@ -3132,7 +3128,7 @@ show_modifytable_info(ModifyTableState *mtstate, List *ancestors,
31323128

31333129
/* count the number of source rows */
31343130
total=mtstate->mt_plans[0]->instrument->ntuples;
3135-
other_path=mtstate->ps.instrument->nfiltered2;
3131+
other_path=mtstate->ps.instrument->ntuples2;
31363132
insert_path=total-other_path;
31373133

31383134
ExplainPropertyFloat("Tuples Inserted",NULL,

‎src/backend/executor/instrument.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ InstrAggNode(Instrumentation *dst, Instrumentation *add)
156156
dst->startup+=add->startup;
157157
dst->total+=add->total;
158158
dst->ntuples+=add->ntuples;
159+
dst->ntuples2+=add->ntuples2;
159160
dst->nloops+=add->nloops;
160161
dst->nfiltered1+=add->nfiltered1;
161162
dst->nfiltered2+=add->nfiltered2;

‎src/backend/executor/nodeIndexonlyscan.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ IndexOnlyNext(IndexOnlyScanState *node)
162162
/*
163163
* Rats, we have to visit the heap to check visibility.
164164
*/
165-
node->ioss_HeapFetches++;
165+
InstrCountTuples2(node,1);
166166
tuple=index_fetch_heap(scandesc);
167167
if (tuple==NULL)
168168
continue;/* no visible tuple, try next index entry */
@@ -509,7 +509,6 @@ ExecInitIndexOnlyScan(IndexOnlyScan *node, EState *estate, int eflags)
509509
indexstate->ss.ps.plan= (Plan*)node;
510510
indexstate->ss.ps.state=estate;
511511
indexstate->ss.ps.ExecProcNode=ExecIndexOnlyScan;
512-
indexstate->ioss_HeapFetches=0;
513512

514513
/*
515514
* Miscellaneous initialization

‎src/backend/executor/nodeModifyTable.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ ExecInsert(ModifyTableState *mtstate,
461461
&conflictTid,planSlot,slot,
462462
estate,canSetTag,&returning))
463463
{
464-
InstrCountFiltered2(&mtstate->ps,1);
464+
InstrCountTuples2(&mtstate->ps,1);
465465
returnreturning;
466466
}
467467
else
@@ -476,7 +476,7 @@ ExecInsert(ModifyTableState *mtstate,
476476
*/
477477
Assert(onconflict==ONCONFLICT_NOTHING);
478478
ExecCheckTIDVisible(estate,resultRelInfo,&conflictTid);
479-
InstrCountFiltered2(&mtstate->ps,1);
479+
InstrCountTuples2(&mtstate->ps,1);
480480
returnNULL;
481481
}
482482
}

‎src/include/executor/instrument.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ typedef struct Instrumentation
5757
doublestartup;/* Total startup time (in seconds) */
5858
doubletotal;/* Total total time (in seconds) */
5959
doublentuples;/* Total tuples produced */
60+
doublentuples2;/* Secondary node-specific tuple counter */
6061
doublenloops;/* # of run cycles for this node */
6162
doublenfiltered1;/* # tuples removed by scanqual or joinqual OR
6263
* # tuples inserted by MERGE */

‎src/include/nodes/execnodes.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,11 @@ typedef struct PlanState
10041004
#defineouterPlanState(node)(((PlanState *)(node))->lefttree)
10051005

10061006
/* Macros for inline access to certain instrumentation counters */
1007+
#defineInstrCountTuples2(node,delta) \
1008+
do { \
1009+
if (((PlanState *)(node))->instrument) \
1010+
((PlanState *)(node))->instrument->ntuples2 += (delta); \
1011+
} while (0)
10071012
#defineInstrCountFiltered1(node,delta) \
10081013
do { \
10091014
if (((PlanState *)(node))->instrument) \
@@ -1368,7 +1373,6 @@ typedef struct IndexScanState
13681373
*RelationDesc index relation descriptor
13691374
*ScanDesc index scan descriptor
13701375
*VMBuffer buffer in use for visibility map testing, if any
1371-
*HeapFetches number of tuples we were forced to fetch from heap
13721376
*ioss_PscanLen Size of parallel index-only scan descriptor
13731377
* ----------------
13741378
*/
@@ -1387,7 +1391,6 @@ typedef struct IndexOnlyScanState
13871391
Relationioss_RelationDesc;
13881392
IndexScanDescioss_ScanDesc;
13891393
Bufferioss_VMBuffer;
1390-
longioss_HeapFetches;
13911394
Sizeioss_PscanLen;
13921395
}IndexOnlyScanState;
13931396

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp