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

Commitb925a00

Browse files
committed
Fix "force_parallel_mode = regress" to work with ANALYZE + VERBOSE.
force_parallel_mode = regress is supposed to force use of a Gathernode without having any impact on EXPLAIN output. But it failed toaccomplish that if both ANALYZE and VERBOSE are given, because thatenables per-worker output data that you wouldn't see if the Gatherhadn't been inserted. Improve the logic so that we suppress theper-worker data too.This allows putting the new test case added by commit5935917back into the originally intended form (cf.776a2c8,22864f6).We can also get rid of a kluge in subselect.sql, which previouslyhad to clean up after force_parallel_mode's failure to do what itsaid on the tin.Discussion:https://postgr.es/m/18445.1576177309@sss.pgh.pa.us
1 parent9067b83 commitb925a00

File tree

6 files changed

+30
-14
lines changed

6 files changed

+30
-14
lines changed

‎src/backend/commands/explain.c

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -695,13 +695,19 @@ ExplainPrintPlan(ExplainState *es, QueryDesc *queryDesc)
695695

696696
/*
697697
* Sometimes we mark a Gather node as "invisible", which means that it's
698-
* not displayed in EXPLAIN output. The purpose of this is to allow
698+
* notto bedisplayed in EXPLAIN output. The purpose of this is to allow
699699
* running regression tests with force_parallel_mode=regress to get the
700700
* same results as running the same tests with force_parallel_mode=off.
701+
* Such marking is currently only supported on a Gather at the top of the
702+
* plan. We skip that node, and we must also hide per-worker detail data
703+
* further down in the plan tree.
701704
*/
702705
ps=queryDesc->planstate;
703706
if (IsA(ps,GatherState)&&((Gather*)ps->plan)->invisible)
707+
{
704708
ps=outerPlanState(ps);
709+
es->hide_workers= true;
710+
}
705711
ExplainNode(ps,NIL,NULL,NULL,es);
706712

707713
/*
@@ -806,6 +812,10 @@ ExplainPrintJIT(ExplainState *es, int jit_flags,
806812
if (!ji||ji->created_functions==0)
807813
return;
808814

815+
/* don't print per-worker info if we're supposed to hide that */
816+
if (for_workers&&es->hide_workers)
817+
return;
818+
809819
/* calculate total time */
810820
INSTR_TIME_SET_ZERO(total_time);
811821
INSTR_TIME_ADD(total_time,ji->generation_counter);
@@ -1877,7 +1887,8 @@ ExplainNode(PlanState *planstate, List *ancestors,
18771887
show_buffer_usage(es,&planstate->instrument->bufusage);
18781888

18791889
/* Show worker detail */
1880-
if (es->analyze&&es->verbose&&planstate->worker_instrument)
1890+
if (es->analyze&&es->verbose&& !es->hide_workers&&
1891+
planstate->worker_instrument)
18811892
{
18821893
WorkerInstrumentation*w=planstate->worker_instrument;
18831894
boolopened_group= false;
@@ -2574,6 +2585,12 @@ show_sort_info(SortState *sortstate, ExplainState *es)
25742585
}
25752586
}
25762587

2588+
/*
2589+
* You might think we should just skip this stanza entirely when
2590+
* es->hide_workers is true, but then we'd get no sort-method output at
2591+
* all. We have to make it look like worker 0's data is top-level data.
2592+
* Currently, we only bother with that for text-format output.
2593+
*/
25772594
if (sortstate->shared_info!=NULL)
25782595
{
25792596
intn;
@@ -2596,9 +2613,11 @@ show_sort_info(SortState *sortstate, ExplainState *es)
25962613
if (es->format==EXPLAIN_FORMAT_TEXT)
25972614
{
25982615
appendStringInfoSpaces(es->str,es->indent*2);
2616+
if (n>0|| !es->hide_workers)
2617+
appendStringInfo(es->str,"Worker %d: ",n);
25992618
appendStringInfo(es->str,
2600-
"Worker %d:Sort Method: %s %s: %ldkB\n",
2601-
n,sortMethod,spaceType,spaceUsed);
2619+
"Sort Method: %s %s: %ldkB\n",
2620+
sortMethod,spaceType,spaceUsed);
26022621
}
26032622
else
26042623
{

‎src/include/commands/explain.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ typedef struct ExplainState
4646
List*rtable_names;/* alias names for RTEs */
4747
List*deparse_cxt;/* context list for deparsing expressions */
4848
Bitmapset*printed_subplans;/* ids of SubPlans we've printed */
49+
boolhide_workers;/* set if we find an invisible Gather */
4950
}ExplainState;
5051

5152
/* Hook for plugins to get control in ExplainOneQuery() */

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3163,12 +3163,12 @@ execute mt_q1(35);
31633163
deallocate mt_q1;
31643164
prepare mt_q2 (int) as select * from ma_test where a >= $1 order by b limit 1;
31653165
-- Ensure output list looks sane when the MergeAppend has no subplans.
3166-
explain (verbose, costs off) execute mt_q2 (35);
3167-
QUERY PLAN
3168-
--------------------------------
3169-
Limit
3166+
explain (analyze,verbose, costs off, summary off, timing off) execute mt_q2 (35);
3167+
QUERY PLAN
3168+
--------------------------------------------
3169+
Limit (actual rows=0 loops=1)
31703170
Output: ma_test.a, ma_test.b
3171-
-> Merge Append
3171+
-> Merge Append (actual rows=0 loops=1)
31723172
Sort Key: ma_test.b
31733173
Subplans Removed: 3
31743174
(5 rows)

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,8 +1166,6 @@ begin
11661166
select * from (select pk,c2 from sq_limit order by c1,pk) as x limit 3
11671167
loop
11681168
ln := regexp_replace(ln, 'Memory: \S*', 'Memory: xxx');
1169-
-- this case might occur if force_parallel_mode is on:
1170-
ln := regexp_replace(ln, 'Worker 0: Sort Method', 'Sort Method');
11711169
return next ln;
11721170
end loop;
11731171
end;

‎src/test/regress/sql/partition_prune.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ deallocate mt_q1;
841841
prepare mt_q2 (int)asselect*from ma_testwhere a>= $1order by blimit1;
842842

843843
-- Ensure output list looks sane when the MergeAppend has no subplans.
844-
explain (verbose, costs off) execute mt_q2 (35);
844+
explain (analyze,verbose, costs off, summary off, timing off) execute mt_q2 (35);
845845

846846
deallocate mt_q2;
847847

‎src/test/regress/sql/subselect.sql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,6 @@ begin
631631
select*from (select pk,c2from sq_limitorder by c1,pk)as xlimit3
632632
loop
633633
ln := regexp_replace(ln,'Memory:\S*','Memory: xxx');
634-
-- this case might occur if force_parallel_mode is on:
635-
ln := regexp_replace(ln,'Worker 0: Sort Method','Sort Method');
636634
return next ln;
637635
end loop;
638636
end;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp