diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2023-01-30 13:50:25 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2023-01-30 13:50:25 -0500 |
commit | 3bef56e11650a33f70adeb6dd442bc2b48bb9b72 (patch) | |
tree | 5a817197ed4f7b1f54abc7349dfab3f17bb946c8 /src/backend/optimizer/plan/planner.c | |
parent | b448f1c8d83f8b65e2f0080c556ee21a7076da25 (diff) | |
download | postgresql-3bef56e11650a33f70adeb6dd442bc2b48bb9b72.tar.gz postgresql-3bef56e11650a33f70adeb6dd442bc2b48bb9b72.zip |
Invent "join domains" to replace the below_outer_join hack.
EquivalenceClasses are now understood as applying within a "join
domain", which is a set of inner-joined relations (possibly underneath
an outer join). We no longer need to treat an EC from below an outer
join as a second-class citizen.
I have hopes of eventually being able to treat outer-join clauses via
EquivalenceClasses, by means of only applying deductions within the
EC's join domain. There are still problems in the way of that, though,
so for now the reconsider_outer_join_clause logic is still here.
I haven't been able to get rid of RestrictInfo.is_pushed_down either,
but I wonder if that could be recast using JoinDomains.
I had to hack one test case in postgres_fdw.sql to make it still test
what it was meant to, because postgres_fdw is inconsistent about
how it deals with quals containing non-shippable expressions; see
https://postgr.es/m/1691374.1671659838@sss.pgh.pa.us. That should
be improved, but I don't think it's within the scope of this patch
series.
Patch by me; thanks to Richard Guo for review.
Discussion: https://postgr.es/m/830269.1656693747@sss.pgh.pa.us
Diffstat (limited to 'src/backend/optimizer/plan/planner.c')
-rw-r--r-- | src/backend/optimizer/plan/planner.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index 8674ad674d9..db5ff6fdca4 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -625,6 +625,7 @@ subquery_planner(PlannerGlobal *glob, Query *parse, root->init_plans = NIL; root->cte_plan_ids = NIL; root->multiexpr_params = NIL; + root->join_domains = NIL; root->eq_classes = NIL; root->ec_merging_done = false; root->last_rinfo_serial = 0; @@ -655,6 +656,13 @@ subquery_planner(PlannerGlobal *glob, Query *parse, root->partColsUpdated = false; /* + * Create the top-level join domain. This won't have valid contents until + * deconstruct_jointree fills it in, but the node needs to exist before + * that so we can build EquivalenceClasses referencing it. + */ + root->join_domains = list_make1(makeNode(JoinDomain)); + + /* * If there is a WITH list, process each WITH query and either convert it * to RTE_SUBQUERY RTE(s) or build an initplan SubPlan structure for it. */ @@ -6534,6 +6542,7 @@ plan_cluster_use_sort(Oid tableOid, Oid indexOid) root->query_level = 1; root->planner_cxt = CurrentMemoryContext; root->wt_param_id = -1; + root->join_domains = list_make1(makeNode(JoinDomain)); /* Build a minimal RTE for the rel */ rte = makeNode(RangeTblEntry); @@ -6655,6 +6664,7 @@ plan_create_index_workers(Oid tableOid, Oid indexOid) root->query_level = 1; root->planner_cxt = CurrentMemoryContext; root->wt_param_id = -1; + root->join_domains = list_make1(makeNode(JoinDomain)); /* * Build a minimal RTE. |