From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Do assorted mop-up in the planner. |
Date: | 2023-01-30 19:13:28 |
Message-ID: | E1pMZao-000l3x-Pb@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
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 95f4e59c3.
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 11086f2f2.
Use constant TRUE for "dummy" clauses when throwing back outer joins.
This improves on a hack I introduced in commit 6a6522529. 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
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/b448f1c8d83f8b65e2f0080c556ee21a7076da25
Modified Files
--------------
contrib/postgres_fdw/postgres_fdw.c | 2 -
src/backend/optimizer/path/allpaths.c | 1 -
src/backend/optimizer/path/clausesel.c | 6 -
src/backend/optimizer/path/costsize.c | 2 -
src/backend/optimizer/path/equivclass.c | 168 ++++----------
src/backend/optimizer/path/joinrels.c | 1 -
src/backend/optimizer/path/pathkeys.c | 40 +---
src/backend/optimizer/plan/analyzejoins.c | 16 +-
src/backend/optimizer/plan/initsplan.c | 371 ++++++------------------------
src/backend/optimizer/plan/planner.c | 7 +-
src/backend/optimizer/prep/prepjointree.c | 112 +++++++--
src/backend/optimizer/util/appendinfo.c | 3 -
src/backend/optimizer/util/inherit.c | 7 +-
src/backend/optimizer/util/orclauses.c | 12 +-
src/backend/optimizer/util/placeholder.c | 97 --------
src/backend/optimizer/util/relnode.c | 21 +-
src/backend/optimizer/util/restrictinfo.c | 123 +++++-----
src/include/nodes/pathnodes.h | 48 +---
src/include/optimizer/paths.h | 3 +-
src/include/optimizer/placeholder.h | 2 -
src/include/optimizer/planmain.h | 2 -
src/include/optimizer/restrictinfo.h | 6 +-
src/test/regress/expected/join.out | 34 ++-
src/test/regress/sql/join.sql | 4 +-
24 files changed, 325 insertions(+), 763 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Munro | 2023-01-31 00:49:58 | pgsql: Refactor rmtree() to use get_dirent_type(). |
Previous Message | Tom Lane | 2023-01-30 16:59:41 | pgsql: Doc: clarify behavior of boolean options in replication commands |