index 52f1a96db5faf24c7c954a9f7182a8929c2e0511..ee0f07a81e97305d89db9abd6ba49713659b904f 100644 (file)
@@ -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);
/* Pass down any tuple bound */
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.