pgsql: Recognize self-contradictory restriction clauses for non-table r

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Recognize self-contradictory restriction clauses for non-table r
Date: 2011-09-24 23:33:51
Message-ID: E1R7bjD-000713-St@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Recognize self-contradictory restriction clauses for non-table relations.

The constraint exclusion feature checks for contradictions among scan
restriction clauses, as well as contradictions between those clauses and a
table's CHECK constraints. The first aspect of this testing can be useful
for non-table relations (such as subqueries or functions-in-FROM), but the
feature was coded with only the CHECK case in mind so we were applying it
only to plain-table RTEs. Move the relation_excluded_by_constraints call
so that it is applied to all RTEs not just plain tables. With the default
setting of constraint_exclusion this results in no extra work, but with
constraint_exclusion = ON we will detect optimizations that we missed
before (at the cost of more planner cycles than we expended before).

Per a gripe from Gunnlaugur Þór Briem. Experimentation with
his example also showed we were not being very bright about the case where
constraint exclusion is proven within a subquery within UNION ALL, so tweak
the code to allow set_append_rel_pathlist to recognize such cases.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/7741dd6590073719688891898e85f0cb73453159

Modified Files
--------------
src/backend/optimizer/path/allpaths.c | 58 ++++++++++++++++++++++-----------
src/backend/optimizer/plan/planner.c | 7 ++--
src/include/optimizer/planner.h | 2 +
3 files changed, 45 insertions(+), 22 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian 2011-09-24 23:38:42 pgsql: Document pgrminclude limitations.
Previous Message pgsql 2011-09-24 15:14:15 pgsql: Tag refs/tags/REL8_4_9 was created