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/optimizer/plan/planner.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/optimizer/plan/planner.c')
-rw-r--r-- | src/backend/optimizer/plan/planner.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index 969f3711389..5f3c7510cdd 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/plan/planner.c,v 1.180 2005/03/17 23:44:26 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/plan/planner.c,v 1.181 2005/03/28 00:58:23 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -422,13 +422,17 @@ preprocess_expression(Query *parse, Node *expr, int kind) expr = flatten_join_alias_vars(parse, expr); /* - * If it's a qual or havingQual, canonicalize it. It seems most - * useful to do this before applying eval_const_expressions, since the - * latter can optimize flattened AND/ORs better than unflattened ones. + * Simplify constant expressions. * - * Note: all processing of a qual expression after this point must be - * careful to maintain AND/OR flatness --- that is, do not generate a - * tree with AND directly under AND, nor OR directly under OR. + * Note: this also flattens nested AND and OR expressions into N-argument + * form. All processing of a qual expression after this point must be + * careful to maintain AND/OR flatness --- that is, do not generate a tree + * with AND directly under AND, nor OR directly under OR. + */ + expr = eval_const_expressions(expr); + + /* + * If it's a qual or havingQual, canonicalize it. */ if (kind == EXPRKIND_QUAL) { @@ -440,11 +444,6 @@ preprocess_expression(Query *parse, Node *expr, int kind) #endif } - /* - * Simplify constant expressions. - */ - expr = eval_const_expressions(expr); - /* Expand SubLinks to SubPlans */ if (parse->hasSubLinks) expr = SS_process_sublinks(expr, (kind == EXPRKIND_QUAL)); |