diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-07-02 23:00:42 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-07-02 23:00:42 +0000 |
| commit | cc5e80b8d1c4bf86aa99b54c938e9048e10bf93a (patch) | |
| tree | 6288e2b3bf66c8b1d30ee6db9b7846251d5ad95a /src/include | |
| parent | ea1e2b948d2dcbd40fb9053e74ae2da27cfd425e (diff) | |
Teach planner about some cases where a restriction clause can be
propagated inside an outer join. In particular, given
LEFT JOIN ON (A = B) WHERE A = constant, we cannot conclude that
B = constant at the top level (B might be null instead), but we
can nonetheless put a restriction B = constant into the quals for
B's relation, since no inner-side rows not meeting that condition
can contribute to the final result. Similarly, given
FULL JOIN USING (J) WHERE J = constant, we can't directly conclude
that either input J variable = constant, but it's OK to push such
quals into each input rel. Per recent gripe from Kim Bisgaard.
Along the way, remove 'valid_everywhere' flag from RestrictInfo,
as on closer analysis it was not being used for anything, and was
defined backwards anyway.
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/nodes/relation.h | 18 | ||||
| -rw-r--r-- | src/include/optimizer/restrictinfo.h | 6 |
2 files changed, 13 insertions, 11 deletions
diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h index 0a2ca0e5f33..2f906c6a472 100644 --- a/src/include/nodes/relation.h +++ b/src/include/nodes/relation.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/nodes/relation.h,v 1.115 2005/06/13 23:14:49 tgl Exp $ + * $PostgreSQL: pgsql/src/include/nodes/relation.h,v 1.116 2005/07/02 23:00:42 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -87,6 +87,15 @@ typedef struct PlannerInfo List *equi_key_list; /* list of lists of equijoined * PathKeyItems */ + List *left_join_clauses; /* list of RestrictInfos for outer join + * clauses w/nonnullable var on left */ + + List *right_join_clauses; /* list of RestrictInfos for outer join + * clauses w/nonnullable var on right */ + + List *full_join_clauses; /* list of RestrictInfos for full outer + * join clauses */ + List *in_info_list; /* list of InClauseInfos */ List *query_pathkeys; /* desired pathkeys for query_planner(), @@ -95,6 +104,7 @@ typedef struct PlannerInfo double tuple_fraction; /* tuple_fraction passed to query_planner */ bool hasJoinRTEs; /* true if any RTEs are RTE_JOIN kind */ + bool hasOuterJoins; /* true if any RTEs are outer joins */ bool hasHavingQual; /* true if havingQual was non-null */ } PlannerInfo; @@ -695,10 +705,6 @@ typedef struct HashPath * joined, will also have is_pushed_down set because it will get attached to * some lower joinrel. * - * We also store a valid_everywhere flag, which says that the clause is not - * affected by any lower-level outer join, and therefore any conditions it - * asserts can be presumed true throughout the plan tree. - * * In general, the referenced clause might be arbitrarily complex. The * kinds of clauses we can handle as indexscan quals, mergejoin clauses, * or hashjoin clauses are fairly limited --- the code for each kind of @@ -725,8 +731,6 @@ typedef struct RestrictInfo bool is_pushed_down; /* TRUE if clause was pushed down in level */ - bool valid_everywhere; /* TRUE if valid on every level */ - /* * This flag is set true if the clause looks potentially useful as a * merge or hash join clause, that is if it is a binary opclause with diff --git a/src/include/optimizer/restrictinfo.h b/src/include/optimizer/restrictinfo.h index 20f51c58204..5a9c2f27224 100644 --- a/src/include/optimizer/restrictinfo.h +++ b/src/include/optimizer/restrictinfo.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/optimizer/restrictinfo.h,v 1.31 2005/06/09 04:19:00 tgl Exp $ + * $PostgreSQL: pgsql/src/include/optimizer/restrictinfo.h,v 1.32 2005/07/02 23:00:42 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -19,11 +19,9 @@ extern RestrictInfo *make_restrictinfo(Expr *clause, bool is_pushed_down, - bool valid_everywhere, Relids required_relids); extern List *make_restrictinfo_from_bitmapqual(Path *bitmapqual, - bool is_pushed_down, - bool valid_everywhere); + bool is_pushed_down); extern bool restriction_is_or_clause(RestrictInfo *restrictinfo); extern List *get_actual_clauses(List *restrictinfo_list); extern void get_actual_join_clauses(List *restrictinfo_list, |
