Skip to content

Commit 5702277

Browse files
committed
Tweak EXPLAIN for parallel query to show workers launched.
The previous display was sort of confusing, because it didn't distinguish between the number of workers that we planned to launch and the number that actually got launched. This has already confused several people, so display both numbers and label them clearly. Julien Rouhaud, reviewed by me.
1 parent 6b85d4b commit 5702277

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/backend/commands/explain.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1339,8 +1339,16 @@ ExplainNode(PlanState *planstate, List *ancestors,
13391339
if (plan->qual)
13401340
show_instrumentation_count("Rows Removed by Filter", 1,
13411341
planstate, es);
1342-
ExplainPropertyInteger("Number of Workers",
1342+
ExplainPropertyInteger("Workers Planned",
13431343
gather->num_workers, es);
1344+
if (es->analyze)
1345+
{
1346+
int nworkers;
1347+
1348+
nworkers = ((GatherState *) planstate)->nworkers_launched;
1349+
ExplainPropertyInteger("Workers Launched",
1350+
nworkers, es);
1351+
}
13441352
if (gather->single_copy)
13451353
ExplainPropertyText("Single Copy",
13461354
gather->single_copy ? "true" : "false",

src/backend/executor/nodeGather.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ ExecGather(GatherState *node)
166166
*/
167167
pcxt = node->pei->pcxt;
168168
LaunchParallelWorkers(pcxt);
169+
node->nworkers_launched = pcxt->nworkers_launched;
169170

170171
/* Set up tuple queue readers to read the results. */
171172
if (pcxt->nworkers_launched > 0)

src/include/nodes/execnodes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1956,6 +1956,7 @@ typedef struct GatherState
19561956
struct ParallelExecutorInfo *pei;
19571957
int nreaders;
19581958
int nextreader;
1959+
int nworkers_launched;
19591960
struct TupleQueueReader **reader;
19601961
TupleTableSlot *funnel_slot;
19611962
bool need_to_scan_locally;

0 commit comments

Comments
 (0)