mirror of
https://github.com/postgres/postgres.git
synced 2025-12-06 00:02:13 +03:00
Revise the planner's handling of "pseudoconstant" WHERE clauses, that is
clauses containing no variables and no volatile functions. Such a clause can be used as a one-time qual in a gating Result plan node, to suppress plan execution entirely when it is false. Even when the clause is true, putting it in a gating node wins by avoiding repeated evaluation of the clause. In previous PG releases, query_planner() would do this for pseudoconstant clauses appearing at the top level of the jointree, but there was no ability to generate a gating Result deeper in the plan tree. To fix it, get rid of the special case in query_planner(), and instead process pseudoconstant clauses through the normal RestrictInfo qual distribution mechanism. When a pseudoconstant clause is found attached to a path node in create_plan(), pull it out and generate a gating Result at that point. This requires special-casing pseudoconstants in selectivity estimation and cost_qual_eval, but on the whole it's pretty clean. It probably even makes the planner a bit faster than before for the normal case of no pseudoconstants, since removing pull_constant_clauses saves one useless traversal of the qual tree. Per gripe from Phil Frost.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/optimizer/restrictinfo.h,v 1.36 2006/03/05 15:58:57 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/include/optimizer/restrictinfo.h,v 1.37 2006/07/01 18:38:33 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -20,14 +20,18 @@
|
||||
extern RestrictInfo *make_restrictinfo(Expr *clause,
|
||||
bool is_pushed_down,
|
||||
bool outerjoin_delayed,
|
||||
bool pseudoconstant,
|
||||
Relids required_relids);
|
||||
extern List *make_restrictinfo_from_bitmapqual(Path *bitmapqual,
|
||||
bool is_pushed_down,
|
||||
bool include_predicates);
|
||||
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,
|
||||
List **joinquals, List **otherquals);
|
||||
extern List *extract_actual_clauses(List *restrictinfo_list,
|
||||
bool pseudoconstant);
|
||||
extern void extract_actual_join_clauses(List *restrictinfo_list,
|
||||
List **joinquals,
|
||||
List **otherquals);
|
||||
extern List *remove_redundant_join_clauses(PlannerInfo *root,
|
||||
List *restrictinfo_list,
|
||||
bool isouterjoin);
|
||||
|
||||
Reference in New Issue
Block a user