mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
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 are wrong 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 use the new ntuples2 instead of nfiltered2, which is a blatant misuse. Discussion: https://postgr.es/m/20180409215851.idwc75ct2bzi6tea@alvherre.pgsql
This commit is contained in:
@ -156,6 +156,7 @@ InstrAggNode(Instrumentation *dst, Instrumentation *add)
|
||||
dst->startup += add->startup;
|
||||
dst->total += add->total;
|
||||
dst->ntuples += add->ntuples;
|
||||
dst->ntuples2 += add->ntuples2;
|
||||
dst->nloops += add->nloops;
|
||||
dst->nfiltered1 += add->nfiltered1;
|
||||
dst->nfiltered2 += add->nfiltered2;
|
||||
|
@ -162,7 +162,7 @@ IndexOnlyNext(IndexOnlyScanState *node)
|
||||
/*
|
||||
* Rats, we have to visit the heap to check visibility.
|
||||
*/
|
||||
node->ioss_HeapFetches++;
|
||||
InstrCountTuples2(node, 1);
|
||||
tuple = index_fetch_heap(scandesc);
|
||||
if (tuple == NULL)
|
||||
continue; /* no visible tuple, try next index entry */
|
||||
@ -509,7 +509,6 @@ ExecInitIndexOnlyScan(IndexOnlyScan *node, EState *estate, int eflags)
|
||||
indexstate->ss.ps.plan = (Plan *) node;
|
||||
indexstate->ss.ps.state = estate;
|
||||
indexstate->ss.ps.ExecProcNode = ExecIndexOnlyScan;
|
||||
indexstate->ioss_HeapFetches = 0;
|
||||
|
||||
/*
|
||||
* Miscellaneous initialization
|
||||
|
@ -461,7 +461,7 @@ ExecInsert(ModifyTableState *mtstate,
|
||||
&conflictTid, planSlot, slot,
|
||||
estate, canSetTag, &returning))
|
||||
{
|
||||
InstrCountFiltered2(&mtstate->ps, 1);
|
||||
InstrCountTuples2(&mtstate->ps, 1);
|
||||
return returning;
|
||||
}
|
||||
else
|
||||
@ -476,7 +476,7 @@ ExecInsert(ModifyTableState *mtstate,
|
||||
*/
|
||||
Assert(onconflict == ONCONFLICT_NOTHING);
|
||||
ExecCheckTIDVisible(estate, resultRelInfo, &conflictTid);
|
||||
InstrCountFiltered2(&mtstate->ps, 1);
|
||||
InstrCountTuples2(&mtstate->ps, 1);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user