1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-09 13:09:39 +03:00

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.
This commit is contained in:
Tom Lane
2005-07-02 23:00:42 +00:00
parent ea1e2b948d
commit cc5e80b8d1
13 changed files with 424 additions and 114 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/optimizer/path/orindxpath.c,v 1.72 2005/06/09 04:18:59 tgl Exp $
* $PostgreSQL: pgsql/src/backend/optimizer/path/orindxpath.c,v 1.73 2005/07/02 23:00:40 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -90,16 +90,13 @@ create_or_index_quals(PlannerInfo *root, RelOptInfo *rel)
ListCell *i;
/*
* Find potentially interesting OR joinclauses. We must ignore any
* joinclauses that are not marked valid_everywhere, because they
* cannot be pushed down due to outer-join rules.
* Find potentially interesting OR joinclauses.
*/
foreach(i, rel->joininfo)
{
RestrictInfo *rinfo = (RestrictInfo *) lfirst(i);
if (restriction_is_or_clause(rinfo) &&
rinfo->valid_everywhere)
if (restriction_is_or_clause(rinfo))
{
/*
* Use the generate_bitmap_or_paths() machinery to estimate
@@ -140,8 +137,7 @@ create_or_index_quals(PlannerInfo *root, RelOptInfo *rel)
* Convert the path's indexclauses structure to a RestrictInfo tree,
* and add it to the rel's restriction list.
*/
newrinfos = make_restrictinfo_from_bitmapqual((Path *) bestpath,
true, true);
newrinfos = make_restrictinfo_from_bitmapqual((Path *) bestpath, true);
Assert(list_length(newrinfos) == 1);
or_rinfo = (RestrictInfo *) linitial(newrinfos);
Assert(IsA(or_rinfo, RestrictInfo));