1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-30 21:42:05 +03:00

Rethink the order of expression preprocessing: eval_const_expressions

really ought to run before canonicalize_qual, because it can now produce
forms that canonicalize_qual knows how to improve (eg, NOT clauses).
Also, because eval_const_expressions already knows about flattening
nested ANDs and ORs into N-argument form, the initial flatten_andors
pass in canonicalize_qual is now completely redundant and can be
removed.  This doesn't save a whole lot of code, but the time and
palloc traffic eliminated is a useful gain on large expression trees.
This commit is contained in:
Tom Lane
2005-03-28 00:58:26 +00:00
parent bf3dbb5881
commit 5db2e83852
7 changed files with 61 additions and 140 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.216 2005/03/07 04:42:16 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.217 2005/03/28 00:58:26 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -2788,14 +2788,11 @@ RelationGetIndexExpressions(Relation relation)
pfree(exprsString);
/*
* Run the expressions through flatten_andors and
* eval_const_expressions. This is not just an optimization, but is
* necessary, because the planner will be comparing them to
* similarly-processed qual clauses, and may fail to detect valid
* matches without this.
* Run the expressions through eval_const_expressions. This is not just an
* optimization, but is necessary, because the planner will be comparing
* them to similarly-processed qual clauses, and may fail to detect valid
* matches without this. We don't bother with canonicalize_qual, however.
*/
result = (List *) flatten_andors((Node *) result);
result = (List *) eval_const_expressions((Node *) result);
/*
@ -2863,16 +2860,18 @@ RelationGetIndexPredicate(Relation relation)
pfree(predString);
/*
* Run the expression through canonicalize_qual and
* eval_const_expressions. This is not just an optimization, but is
* necessary, because the planner will be comparing it to
* similarly-processed qual clauses, and may fail to detect valid
* matches without this.
* Run the expression through const-simplification and canonicalization.
* This is not just an optimization, but is necessary, because the planner
* will be comparing it to similarly-processed qual clauses, and may fail
* to detect valid matches without this. This must match the processing
* done to qual clauses in preprocess_expression()! (We can skip the
* stuff involving subqueries, however, since we don't allow any in
* index predicates.)
*/
result = (List *) canonicalize_qual((Expr *) result);
result = (List *) eval_const_expressions((Node *) result);
result = (List *) canonicalize_qual((Expr *) result);
/*
* Also mark any coercion format fields as "don't care", so that the
* planner can match to both explicit and implicit coercions.