mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
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.
This commit is contained in:
@ -60,7 +60,6 @@ static Node *preprocess_expression(PlannerInfo *root, Node *expr, int kind);
|
||||
static void preprocess_qual_conditions(PlannerInfo *root, Node *jtnode);
|
||||
static Plan *inheritance_planner(PlannerInfo *root);
|
||||
static Plan *grouping_planner(PlannerInfo *root, double tuple_fraction);
|
||||
static bool is_dummy_plan(Plan *plan);
|
||||
static void preprocess_rowmarks(PlannerInfo *root);
|
||||
static double preprocess_limit(PlannerInfo *root,
|
||||
double tuple_fraction,
|
||||
@ -1841,9 +1840,11 @@ grouping_planner(PlannerInfo *root, double tuple_fraction)
|
||||
* is deemed not to need scanning due to constraint exclusion.
|
||||
*
|
||||
* Currently, such dummy plans are Result nodes with constant FALSE
|
||||
* filter quals.
|
||||
* filter quals (see set_dummy_rel_pathlist and create_append_plan).
|
||||
*
|
||||
* XXX this probably ought to be somewhere else, but not clear where.
|
||||
*/
|
||||
static bool
|
||||
bool
|
||||
is_dummy_plan(Plan *plan)
|
||||
{
|
||||
if (IsA(plan, Result))
|
||||
|
Reference in New Issue
Block a user