Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit72567f6

Browse files
committed
Try again to fix accumulation of parallel worker instrumentation.
When a Gather or Gather Merge node is started and stopped multipletimes, accumulate instrumentation data only once, at the end, insteadof after each execution, to avoid recording inflated totals.Commit778e78a, the previous attemptat a fix, instead reset the state after every execution, which workedfor the general instrumentation data but had problems for the additionalinstrumentation specific to Sort and Hash nodes.Report by hubert depesz lubaczewski. Analysis and fix by Amit Kapila,following a design proposal from Thomas Munro, with a comment tweakby me.Discussion:http://postgr.es/m/20171127175631.GA405@depesz.com
1 parentdb2ee07 commit72567f6

File tree

3 files changed

+38
-10
lines changed

3 files changed

+38
-10
lines changed

‎src/backend/executor/execParallel.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ ExecParallelRetrieveInstrumentation(PlanState *planstate,
723723

724724
/*
725725
* Finish parallel execution. We wait for parallel workers to finish, and
726-
* accumulate their buffer usage and instrumentation.
726+
* accumulate their buffer usage.
727727
*/
728728
void
729729
ExecParallelFinish(ParallelExecutorInfo*pei)
@@ -769,23 +769,23 @@ ExecParallelFinish(ParallelExecutorInfo *pei)
769769
for (i=0;i<nworkers;i++)
770770
InstrAccumParallelQuery(&pei->buffer_usage[i]);
771771

772-
/* Finally, accumulate instrumentation, if any. */
773-
if (pei->instrumentation)
774-
ExecParallelRetrieveInstrumentation(pei->planstate,
775-
pei->instrumentation);
776-
777772
pei->finished= true;
778773
}
779774

780775
/*
781-
*Clean up whatever ParallelExecutorInfo resources still exist after
782-
* ExecParallelFinish. We separate these routines because someone might
783-
* want to examine the contents of the DSM after ExecParallelFinish and
784-
* before calling this routine.
776+
*Accumulate instrumentation, and then clean up whatever ParallelExecutorInfo
777+
*resources still exist afterExecParallelFinish. We separate these
778+
*routines because someone mightwant to examine the contents of the DSM
779+
*after ExecParallelFinish andbefore calling this routine.
785780
*/
786781
void
787782
ExecParallelCleanup(ParallelExecutorInfo*pei)
788783
{
784+
/* Accumulate instrumentation, if any. */
785+
if (pei->instrumentation)
786+
ExecParallelRetrieveInstrumentation(pei->planstate,
787+
pei->instrumentation);
788+
789789
if (pei->area!=NULL)
790790
{
791791
dsa_detach(pei->area);

‎src/test/regress/expected/select_parallel.out

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,28 @@ select count(*) from bmscantest where a>1;
300300
99999
301301
(1 row)
302302

303+
-- test accumulation of stats for parallel nodes
303304
reset enable_seqscan;
305+
alter table tenk2 set (parallel_workers = 0);
306+
explain (analyze, timing off, summary off, costs off)
307+
select count(*) from tenk1, tenk2 where tenk1.hundred > 1
308+
and tenk2.thousand=0;
309+
QUERY PLAN
310+
--------------------------------------------------------------------------
311+
Aggregate (actual rows=1 loops=1)
312+
-> Nested Loop (actual rows=98000 loops=1)
313+
-> Seq Scan on tenk2 (actual rows=10 loops=1)
314+
Filter: (thousand = 0)
315+
Rows Removed by Filter: 9990
316+
-> Gather (actual rows=9800 loops=10)
317+
Workers Planned: 4
318+
Workers Launched: 4
319+
-> Parallel Seq Scan on tenk1 (actual rows=1960 loops=50)
320+
Filter: (hundred > 1)
321+
Rows Removed by Filter: 40
322+
(11 rows)
323+
324+
alter table tenk2 reset (parallel_workers);
304325
reset enable_indexscan;
305326
reset enable_hashjoin;
306327
reset enable_mergejoin;

‎src/test/regress/sql/select_parallel.sql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,14 @@ insert into bmscantest select r, 'fooooooooooooooooooooooooooooooooooooooooooooo
116116
createindexi_bmtestON bmscantest(a);
117117
selectcount(*)from bmscantestwhere a>1;
118118

119+
-- test accumulation of stats for parallel nodes
119120
reset enable_seqscan;
121+
altertable tenk2set (parallel_workers=0);
122+
explain (analyze, timing off, summary off, costs off)
123+
selectcount(*)from tenk1, tenk2wheretenk1.hundred>1
124+
andtenk2.thousand=0;
125+
altertable tenk2 reset (parallel_workers);
126+
120127
reset enable_indexscan;
121128
reset enable_hashjoin;
122129
reset enable_mergejoin;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp