mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +03:00
Allow parallel workers to execute subplans.
This doesn't do anything to make Param nodes anything other than parallel-restricted, so this only helps with uncorrelated subplans, and it's not necessarily very cheap because each worker will run the subplan separately (just as a Hash Join will build a separate copy of the hash table in each participating process), but it's a first step toward supporting cases that are more likely to help in practice, and is occasionally useful on its own. Amit Kapila, reviewed and tested by Rafia Sabih, Dilip Kumar, and me. Discussion: http://postgr.es/m/CAA4eK1+e8Z45D2n+rnDMDYsVEb5iW7jqaCH_tvPMYau=1Rru9w@mail.gmail.com
This commit is contained in:
@ -58,7 +58,7 @@ static Node *build_subplan(PlannerInfo *root, Plan *plan, PlannerInfo *subroot,
|
||||
List *plan_params,
|
||||
SubLinkType subLinkType, int subLinkId,
|
||||
Node *testexpr, bool adjust_testexpr,
|
||||
bool unknownEqFalse);
|
||||
bool unknownEqFalse, bool parallel_safe);
|
||||
static List *generate_subquery_params(PlannerInfo *root, List *tlist,
|
||||
List **paramIds);
|
||||
static List *generate_subquery_vars(PlannerInfo *root, List *tlist,
|
||||
@ -551,7 +551,8 @@ make_subplan(PlannerInfo *root, Query *orig_subquery,
|
||||
/* And convert to SubPlan or InitPlan format. */
|
||||
result = build_subplan(root, plan, subroot, plan_params,
|
||||
subLinkType, subLinkId,
|
||||
testexpr, true, isTopQual);
|
||||
testexpr, true, isTopQual,
|
||||
best_path->parallel_safe);
|
||||
|
||||
/*
|
||||
* If it's a correlated EXISTS with an unimportant targetlist, we might be
|
||||
@ -604,7 +605,8 @@ make_subplan(PlannerInfo *root, Query *orig_subquery,
|
||||
plan_params,
|
||||
ANY_SUBLINK, 0,
|
||||
newtestexpr,
|
||||
false, true);
|
||||
false, true,
|
||||
best_path->parallel_safe);
|
||||
/* Check we got what we expected */
|
||||
Assert(IsA(hashplan, SubPlan));
|
||||
Assert(hashplan->parParam == NIL);
|
||||
@ -634,7 +636,7 @@ build_subplan(PlannerInfo *root, Plan *plan, PlannerInfo *subroot,
|
||||
List *plan_params,
|
||||
SubLinkType subLinkType, int subLinkId,
|
||||
Node *testexpr, bool adjust_testexpr,
|
||||
bool unknownEqFalse)
|
||||
bool unknownEqFalse, bool parallel_safe)
|
||||
{
|
||||
Node *result;
|
||||
SubPlan *splan;
|
||||
@ -653,6 +655,7 @@ build_subplan(PlannerInfo *root, Plan *plan, PlannerInfo *subroot,
|
||||
&splan->firstColCollation);
|
||||
splan->useHashTable = false;
|
||||
splan->unknownEqFalse = unknownEqFalse;
|
||||
splan->parallel_safe = parallel_safe;
|
||||
splan->setParam = NIL;
|
||||
splan->parParam = NIL;
|
||||
splan->args = NIL;
|
||||
@ -1213,6 +1216,12 @@ SS_process_ctes(PlannerInfo *root)
|
||||
&splan->firstColCollation);
|
||||
splan->useHashTable = false;
|
||||
splan->unknownEqFalse = false;
|
||||
|
||||
/*
|
||||
* CTE scans are not considered for parallelism (cf
|
||||
* set_rel_consider_parallel).
|
||||
*/
|
||||
splan->parallel_safe = false;
|
||||
splan->setParam = NIL;
|
||||
splan->parParam = NIL;
|
||||
splan->args = NIL;
|
||||
|
Reference in New Issue
Block a user