diff options
author | Amit Kapila <akapila@postgresql.org> | 2018-08-03 10:07:56 +0530 |
---|---|---|
committer | Amit Kapila <akapila@postgresql.org> | 2018-08-03 10:07:56 +0530 |
commit | 7124c93fb54fdd3bcf98e29392fc66ddb81f5343 (patch) | |
tree | 55c213b2edc0be57b9e7d4e311c1865a0268b809 /src/backend/executor | |
parent | 764e21db0e2eb384785f94bc0087229318250f9e (diff) |
Match the buffer usage tracking for leader and worker backends.
In the leader backend, we don't track the buffer usage for ExecutorStart
phase whereas in worker backend we track it for ExecutorStart phase as
well. This leads to different value for buffer usage stats for the
parallel and non-parallel query. Change the code so that worker backend
also starts tracking buffer usage after ExecutorStart.
Author: Amit Kapila and Robert Haas
Reviewed-by: Robert Haas and Andres Freund
Backpatch-through: 9.6 where this code was introduced
Discussion: https://postgr.es/m/86137f17-1dfb-42f9-7421-82fd786b04a1@anayrat.info
Diffstat (limited to 'src/backend/executor')
-rw-r--r-- | src/backend/executor/execParallel.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/backend/executor/execParallel.c b/src/backend/executor/execParallel.c index 6eed6db3355..b1a3d91a196 100644 --- a/src/backend/executor/execParallel.c +++ b/src/backend/executor/execParallel.c @@ -735,12 +735,19 @@ ParallelQueryMain(dsm_segment *seg, shm_toc *toc) instrument_options = instrumentation->instrument_options; queryDesc = ExecParallelGetQueryDesc(toc, receiver, instrument_options); - /* Prepare to track buffer usage during query execution. */ - InstrStartParallelQuery(); - /* Start up the executor, have it run the plan, and then shut it down. */ ExecutorStart(queryDesc, 0); ExecParallelInitializeWorker(queryDesc->planstate, toc); + + /* + * Prepare to track buffer usage during query execution. + * + * We do this after starting up the executor to match what happens in the + * leader, which also doesn't count buffer accesses that occur during + * executor startup. + */ + InstrStartParallelQuery(); + ExecutorRun(queryDesc, ForwardScanDirection, 0L); ExecutorFinish(queryDesc); |