diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index 09b8169b6c7..d8b46a11f45 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -1548,10 +1548,7 @@ ExecutePlan(EState *estate, if (numberTuples || dest->mydest == DestIntoRel) use_parallel_mode = false; - /* - * If a tuple count was supplied, we must force the plan to run without - * parallelism, because we might exit early. - */ + estate->es_use_parallel_mode = use_parallel_mode; if (use_parallel_mode) EnterParallelMode(); diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c index a3bcb100dad..54c60a8d445 100644 --- a/src/backend/executor/execUtils.c +++ b/src/backend/executor/execUtils.c @@ -140,6 +140,8 @@ CreateExecutorState(void) estate->es_epqTupleSet = NULL; estate->es_epqScanDone = NULL; + estate->es_use_parallel_mode = false; + /* * Return the executor state structure */ diff --git a/src/backend/executor/nodeGather.c b/src/backend/executor/nodeGather.c index 7342aadfbb4..216759aeab1 100644 --- a/src/backend/executor/nodeGather.c +++ b/src/backend/executor/nodeGather.c @@ -150,7 +150,7 @@ ExecGather(GatherState *node) * Sometimes we might have to run without parallelism; but if parallel * mode is active then we can try to fire up some workers. */ - if (gather->num_workers > 0 && IsInParallelMode()) + if (gather->num_workers > 0 && estate->es_use_parallel_mode) { ParallelContext *pcxt; diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index 53a247ca5df..7621a171671 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -421,6 +421,8 @@ typedef struct EState HeapTuple *es_epqTuple; /* array of EPQ substitute tuples */ bool *es_epqTupleSet; /* true if EPQ tuple is provided */ bool *es_epqScanDone; /* true if EPQ tuple has been fetched */ + + bool es_use_parallel_mode; /* can we use parallel workers? */ } EState;