summaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorAlvaro Herrera2018-04-10 18:56:15 +0000
committerAlvaro Herrera2018-04-10 18:56:15 +0000
commit15a8f8caad14c1f85b23d97842d0c27b106cc10e (patch)
tree764375ef544e9c6b7f61c8dcd8b6ba6549f97c97 /src/backend
parent1a40485af6e43be501500a88b1b9765cc0d69c0b (diff)
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
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/commands/explain.c10
-rw-r--r--src/backend/executor/instrument.c1
-rw-r--r--src/backend/executor/nodeIndexonlyscan.c3
-rw-r--r--src/backend/executor/nodeModifyTable.c4
4 files changed, 7 insertions, 11 deletions
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
index 989b6aad67b..306e6444669 100644
--- a/src/backend/commands/explain.c
+++ b/src/backend/commands/explain.c
@@ -1459,12 +1459,8 @@ ExplainNode(PlanState *planstate, List *ancestors,
show_instrumentation_count("Rows Removed by Filter", 1,
planstate, es);
if (es->analyze)
- {
- long heapFetches =
- ((IndexOnlyScanState *) planstate)->ioss_HeapFetches;
-
- ExplainPropertyInteger("Heap Fetches", NULL, heapFetches, es);
- }
+ ExplainPropertyFloat("Heap Fetches", NULL,
+ planstate->instrument->ntuples2, 0, es);
break;
case T_BitmapIndexScan:
show_scan_qual(((BitmapIndexScan *) plan)->indexqualorig,
@@ -3132,7 +3128,7 @@ show_modifytable_info(ModifyTableState *mtstate, List *ancestors,
/* count the number of source rows */
total = mtstate->mt_plans[0]->instrument->ntuples;
- other_path = mtstate->ps.instrument->nfiltered2;
+ other_path = mtstate->ps.instrument->ntuples2;
insert_path = total - other_path;
ExplainPropertyFloat("Tuples Inserted", NULL,
diff --git a/src/backend/executor/instrument.c b/src/backend/executor/instrument.c
index 86252cee1f3..fe5d55904d2 100644
--- a/src/backend/executor/instrument.c
+++ b/src/backend/executor/instrument.c
@@ -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;
diff --git a/src/backend/executor/nodeIndexonlyscan.c b/src/backend/executor/nodeIndexonlyscan.c
index ddc0ae90615..3a02a996214 100644
--- a/src/backend/executor/nodeIndexonlyscan.c
+++ b/src/backend/executor/nodeIndexonlyscan.c
@@ -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
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index f47649d0517..543a735be2b 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -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;
}
}