summaryrefslogtreecommitdiff
path: root/src/backend/optimizer/util/clauses.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2017-02-14 18:09:47 -0500
committerRobert Haas <rhaas@postgresql.org>2017-02-14 18:16:03 -0500
commit5e6d8d2bbbcace304450b309e79366c0da4063e4 (patch)
treed5068ced430d295491c0b34c39415e8f49fad6da /src/backend/optimizer/util/clauses.c
parent8da9a226369e9ceec7cef1ab7a16cdc0adb4d657 (diff)
downloadpostgresql-5e6d8d2bbbcace304450b309e79366c0da4063e4.tar.gz
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
Diffstat (limited to 'src/backend/optimizer/util/clauses.c')
-rw-r--r--src/backend/optimizer/util/clauses.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c
index d589dc2544..3dedee6d69 100644
--- a/src/backend/optimizer/util/clauses.c
+++ b/src/backend/optimizer/util/clauses.c
@@ -1162,21 +1162,19 @@ max_parallel_hazard_walker(Node *node, max_parallel_hazard_context *context)
}
/*
- * Since we don't have the ability to push subplans down to workers at
- * present, we treat subplan references as parallel-restricted. We need
- * not worry about examining their contents; if they are unsafe, we would
- * have found that out while examining the whole tree before reduction of
- * sublinks to subplans. (Really we should not see SubLink during a
- * max_interesting == restricted scan, but if we do, return true.)
+ * Really we should not see SubLink during a max_interesting == restricted
+ * scan, but if we do, return true.
*/
- else if (IsA(node, SubLink) ||
- IsA(node, SubPlan) ||
- IsA(node, AlternativeSubPlan))
+ else if (IsA(node, SubLink))
{
if (max_parallel_hazard_test(PROPARALLEL_RESTRICTED, context))
return true;
}
+ /* We can push the subplans only if they are parallel-safe. */
+ else if (IsA(node, SubPlan))
+ return !((SubPlan *) node)->parallel_safe;
+
/*
* We can't pass Params to workers at the moment either, so they are also
* parallel-restricted.