diff options
Diffstat (limited to 'src/backend/optimizer/plan')
-rw-r--r-- | src/backend/optimizer/plan/planmain.c | 12 | ||||
-rw-r--r-- | src/backend/optimizer/plan/planner.c | 9 |
2 files changed, 17 insertions, 4 deletions
diff --git a/src/backend/optimizer/plan/planmain.c b/src/backend/optimizer/plan/planmain.c index 848df97013e..d73e7c0ab0f 100644 --- a/src/backend/optimizer/plan/planmain.c +++ b/src/backend/optimizer/plan/planmain.c @@ -20,6 +20,7 @@ */ #include "postgres.h" +#include "optimizer/clauses.h" #include "optimizer/orclauses.h" #include "optimizer/pathnode.h" #include "optimizer/paths.h" @@ -70,6 +71,17 @@ query_planner(PlannerInfo *root, List *tlist, /* We need a dummy joinrel to describe the empty set of baserels */ final_rel = build_empty_join_rel(root); + /* + * If query allows parallelism in general, check whether the quals + * are parallel-restricted. There's currently no real benefit to + * setting this flag correctly because we can't yet reference subplans + * from parallel workers. But that might change someday, so set this + * correctly anyway. + */ + if (root->glob->parallelModeOK) + final_rel->consider_parallel = + !has_parallel_hazard(parse->jointree->quals, false); + /* The only path for it is a trivial Result path */ add_path(final_rel, (Path *) create_result_path((List *) parse->jointree->quals)); diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index fa1ab3a46c3..a9cccee7d74 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -204,7 +204,8 @@ standard_planner(Query *parse, int cursorOptions, ParamListInfo boundParams) /* * Assess whether it's feasible to use parallel mode for this query. * We can't do this in a standalone backend, or if the command will - * try to modify any data, or if this is a cursor operation, or if any + * try to modify any data, or if this is a cursor operation, or if + * GUCs are set to values that don't permit parallelism, or if * parallel-unsafe functions are present in the query tree. * * For now, we don't try to use parallel mode if we're running inside @@ -223,9 +224,9 @@ standard_planner(Query *parse, int cursorOptions, ParamListInfo boundParams) glob->parallelModeOK = (cursorOptions & CURSOR_OPT_PARALLEL_OK) != 0 && IsUnderPostmaster && dynamic_shared_memory_type != DSM_IMPL_NONE && parse->commandType == CMD_SELECT && !parse->hasModifyingCTE && - parse->utilityStmt == NULL && !IsParallelWorker() && - !IsolationIsSerializable() && - !contain_parallel_unsafe((Node *) parse); + parse->utilityStmt == NULL && max_parallel_degree > 0 && + !IsParallelWorker() && !IsolationIsSerializable() && + !has_parallel_hazard((Node *) parse, true); /* * glob->parallelModeOK should tell us whether it's necessary to impose |