diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-03-28 00:58:26 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-03-28 00:58:26 +0000 |
commit | 5db2e83852cc3f25fdea48c4aa0da8696c88a826 (patch) | |
tree | 1b6db39b1a6af12052bb93f1a7892a46a0a504d7 /src/backend/utils/cache/relcache.c | |
parent | bf3dbb5881e9b886ee9fe84bca2153c698eea885 (diff) | |
download | postgresql-5db2e83852cc3f25fdea48c4aa0da8696c88a826.tar.gz postgresql-5db2e83852cc3f25fdea48c4aa0da8696c88a826.zip |
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.
Diffstat (limited to 'src/backend/utils/cache/relcache.c')
-rw-r--r-- | src/backend/utils/cache/relcache.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index d1143381d2d..a6660fc4d32 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -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. |