diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-04-16 20:42:16 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-04-16 20:42:16 +0000 |
commit | d7a6a04dc75ebf19cc97d65977801a63756582d9 (patch) | |
tree | bc40b9296cbaee69c50bc4a5d008ead0fada3e7e /src/include/optimizer/restrictinfo.h | |
parent | c5593d54056a95b7616089b2f59bf97eec02af9e (diff) | |
download | postgresql-d7a6a04dc75ebf19cc97d65977801a63756582d9.tar.gz postgresql-d7a6a04dc75ebf19cc97d65977801a63756582d9.zip |
Fix planner to restore its previous level of intelligence about pushing
constants through full joins, as in
select * from tenk1 a full join tenk1 b using (unique1)
where unique1 = 42;
which should generate a fairly cheap plan where we apply the constraint
unique1 = 42 in each relation scan. This had been broken by my patch of
2008-06-27, which is now reverted in favor of a more invasive but hopefully
less incorrect approach. That patch was meant to prevent incorrect extraction
of OR'd indexclauses from OR conditions above an outer join. To do that
correctly we need more information than the outerjoin_delay flag can provide,
so add a nullable_relids field to RestrictInfo that records exactly which
relations are nulled by outer joins that are underneath a particular qual
clause. A side benefit is that we can make the test in create_or_index_quals
more specific: it is now smart enough to extract an OR'd indexclause into the
outer side of an outer join, even though it must not do so in the inner side.
The old coding couldn't distinguish these cases so it could not do either.
Diffstat (limited to 'src/include/optimizer/restrictinfo.h')
-rw-r--r-- | src/include/optimizer/restrictinfo.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/include/optimizer/restrictinfo.h b/src/include/optimizer/restrictinfo.h index 7791afe947b..52d256ed284 100644 --- a/src/include/optimizer/restrictinfo.h +++ b/src/include/optimizer/restrictinfo.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/optimizer/restrictinfo.h,v 1.42 2009/01/01 17:24:00 momjian Exp $ + * $PostgreSQL: pgsql/src/include/optimizer/restrictinfo.h,v 1.43 2009/04/16 20:42:16 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -17,11 +17,16 @@ #include "nodes/relation.h" +/* Convenience macro for the common case of a valid-everywhere qual */ +#define make_simple_restrictinfo(clause) \ + make_restrictinfo(clause, true, false, false, NULL, NULL) + extern RestrictInfo *make_restrictinfo(Expr *clause, bool is_pushed_down, bool outerjoin_delayed, bool pseudoconstant, - Relids required_relids); + Relids required_relids, + Relids nullable_relids); extern List *make_restrictinfo_from_bitmapqual(Path *bitmapqual, bool is_pushed_down, bool include_predicates); |