diff options
author | Amit Kapila <akapila@postgresql.org> | 2018-08-03 09:29:45 +0530 |
---|---|---|
committer | Amit Kapila <akapila@postgresql.org> | 2018-08-03 09:29:45 +0530 |
commit | ef305bd59d9828805bfdbf33ff4003bb74a63865 (patch) | |
tree | da5bb1657bb3d18b5bfb22615f3051f4c762a68a | |
parent | 1b54e91faabf3764b6786915881e514e42dccf89 (diff) | |
download | postgresql-ef305bd59d9828805bfdbf33ff4003bb74a63865.tar.gz postgresql-ef305bd59d9828805bfdbf33ff4003bb74a63865.zip |
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
-rw-r--r-- | src/backend/executor/execParallel.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/backend/executor/execParallel.c b/src/backend/executor/execParallel.c index 52f1a96db5f..ee0f07a81e9 100644 --- a/src/backend/executor/execParallel.c +++ b/src/backend/executor/execParallel.c @@ -1281,9 +1281,6 @@ ParallelQueryMain(dsm_segment *seg, shm_toc *toc) /* Report workers' query for monitoring purposes */ pgstat_report_activity(STATE_RUNNING, debug_query_string); - /* Prepare to track buffer usage during query execution. */ - InstrStartParallelQuery(); - /* Attach to the dynamic shared memory area. */ area_space = shm_toc_lookup(toc, PARALLEL_KEY_DSA, false); area = dsa_attach_in_place(area_space, seg); @@ -1310,6 +1307,15 @@ ParallelQueryMain(dsm_segment *seg, shm_toc *toc) ExecSetTupleBound(fpes->tuples_needed, queryDesc->planstate); /* + * 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(); + + /* * Run the plan. If we specified a tuple bound, be careful not to demand * more tuples than that. */ |