Skip to content

Commit b448f1c

Browse files
committed
Do assorted mop-up in the planner.
Remove RestrictInfo.nullable_relids, along with a good deal of infrastructure that calculated it. One use-case for it was in join_clause_is_movable_to, but we can now replace that usage with a check to see if the clause's relids include any outer join that can null the target relation. The other use-case was in join_clause_is_movable_into, but that test can just be dropped entirely now that the clause's relids include outer joins. Furthermore, join_clause_is_movable_into should now be accurate enough that it will accept anything returned by generate_join_implied_equalities, so we can restore the Assert that was diked out in commit 95f4e59. Remove the outerjoin_delayed mechanism. We needed this before to prevent quals from getting evaluated below outer joins that should null some of their vars. Now that we consider varnullingrels while placing quals, that's taken care of automatically, so throw the whole thing away. Teach remove_useless_result_rtes to also remove useless FromExprs. Having done that, the delay_upper_joins flag serves no purpose any more and we can remove it, largely reverting 11086f2. Use constant TRUE for "dummy" clauses when throwing back outer joins. This improves on a hack I introduced in commit 6a65225. If we have a left-join clause l.x = r.y, and a WHERE clause l.x = constant, we generate r.y = constant and then don't really have a need for the join clause. But we must throw the join clause back anyway after marking it redundant, so that the join search heuristics won't think this is a clauseless join and avoid it. That was a kluge introduced under time pressure, and after looking at it I thought of a better way: let's just introduce constant-TRUE "join clauses" instead, and get rid of them at the end. This improves the generated plans for such cases by not having to test a redundant join clause. We can also get rid of the ugly hack used to mark such clauses as redundant for selectivity estimation. Patch by me; thanks to Richard Guo for review. Discussion: https://postgr.es/m/830269.1656693747@sss.pgh.pa.us
1 parent 2489d76 commit b448f1c

24 files changed

+325
-763
lines changed

contrib/postgres_fdw/postgres_fdw.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6522,10 +6522,8 @@ foreign_grouping_ok(PlannerInfo *root, RelOptInfo *grouped_rel,
65226522
expr,
65236523
true,
65246524
false,
6525-
false,
65266525
root->qual_security_level,
65276526
grouped_rel->relids,
6528-
NULL,
65296527
NULL);
65306528
if (is_foreign_expr(root, grouped_rel, expr))
65316529
fpinfo->remote_conds = lappend(fpinfo->remote_conds, rinfo);

src/backend/optimizer/path/allpaths.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2745,7 +2745,6 @@ set_function_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
27452745
if (var)
27462746
pathkeys = build_expression_pathkey(root,
27472747
(Expr *) var,
2748-
NULL, /* below outer joins */
27492748
Int8LessOperator,
27502749
rel->relids,
27512750
false);

src/backend/optimizer/path/clausesel.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -715,12 +715,6 @@ clause_selectivity_ext(PlannerInfo *root,
715715
return (Selectivity) 1.0;
716716
}
717717

718-
/*
719-
* If the clause is marked redundant, always return 1.0.
720-
*/
721-
if (rinfo->norm_selec > 1)
722-
return (Selectivity) 1.0;
723-
724718
/*
725719
* If possible, cache the result of the selectivity calculation for
726720
* the clause. We can cache if varRelid is zero or the clause

src/backend/optimizer/path/costsize.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4787,7 +4787,6 @@ compute_semi_anti_join_factors(PlannerInfo *root,
47874787
norm_sjinfo.commute_below = NULL;
47884788
/* we don't bother trying to make the remaining fields valid */
47894789
norm_sjinfo.lhs_strict = false;
4790-
norm_sjinfo.delay_upper_joins = false;
47914790
norm_sjinfo.semi_can_btree = false;
47924791
norm_sjinfo.semi_can_hash = false;
47934792
norm_sjinfo.semi_operators = NIL;
@@ -4956,7 +4955,6 @@ approx_tuple_count(PlannerInfo *root, JoinPath *path, List *quals)
49564955
sjinfo.commute_below = NULL;
49574956
/* we don't bother trying to make the remaining fields valid */
49584957
sjinfo.lhs_strict = false;
4959-
sjinfo.delay_upper_joins = false;
49604958
sjinfo.semi_can_btree = false;
49614959
sjinfo.semi_can_hash = false;
49624960
sjinfo.semi_operators = NIL;

0 commit comments

Comments
 (0)