/*
* Sometimes we mark a Gather node as "invisible", which means that it's
- * not displayed in EXPLAIN output. The purpose of this is to allow
+ * not to be displayed in EXPLAIN output. The purpose of this is to allow
* running regression tests with force_parallel_mode=regress to get the
* same results as running the same tests with force_parallel_mode=off.
+ * Such marking is currently only supported on a Gather at the top of the
+ * plan. We skip that node, and we must also hide per-worker detail data
+ * further down in the plan tree.
*/
ps = queryDesc->planstate;
if (IsA(ps, GatherState) &&((Gather *) ps->plan)->invisible)
+ {
ps = outerPlanState(ps);
+ es->hide_workers = true;
+ }
ExplainNode(ps, NIL, NULL, NULL, es);
/*
if (!ji || ji->created_functions == 0)
return;
+ /* don't print per-worker info if we're supposed to hide that */
+ if (for_workers && es->hide_workers)
+ return;
+
/* calculate total time */
INSTR_TIME_SET_ZERO(total_time);
INSTR_TIME_ADD(total_time, ji->generation_counter);
show_buffer_usage(es, &planstate->instrument->bufusage);
/* Show worker detail */
- if (es->analyze && es->verbose && planstate->worker_instrument)
+ if (es->analyze && es->verbose && !es->hide_workers &&
+ planstate->worker_instrument)
{
WorkerInstrumentation *w = planstate->worker_instrument;
bool opened_group = false;
}
}
+ /*
+ * You might think we should just skip this stanza entirely when
+ * es->hide_workers is true, but then we'd get no sort-method output at
+ * all. We have to make it look like worker 0's data is top-level data.
+ * Currently, we only bother with that for text-format output.
+ */
if (sortstate->shared_info != NULL)
{
int n;
if (es->format == EXPLAIN_FORMAT_TEXT)
{
appendStringInfoSpaces(es->str, es->indent * 2);
+ if (n > 0 || !es->hide_workers)
+ appendStringInfo(es->str, "Worker %d: ", n);
appendStringInfo(es->str,
- "Worker %d: Sort Method: %s %s: %ldkB\n",
- n, sortMethod, spaceType, spaceUsed);
+ "Sort Method: %s %s: %ldkB\n",
+ sortMethod, spaceType, spaceUsed);
}
else
{
deallocate mt_q1;
prepare mt_q2 (int) as select * from ma_test where a >= $1 order by b limit 1;
-- Ensure output list looks sane when the MergeAppend has no subplans.
-explain (verbose, costs off) execute mt_q2 (35);
- QUERY PLAN
---------------------------------
- Limit
+explain (analyze, verbose, costs off, summary off, timing off) execute mt_q2 (35);
+ QUERY PLAN
+--------------------------------------------
+ Limit (actual rows=0 loops=1)
Output: ma_test.a, ma_test.b
- -> Merge Append
+ -> Merge Append (actual rows=0 loops=1)
Sort Key: ma_test.b
Subplans Removed: 3
(5 rows)