mirror of
https://github.com/postgres/postgres.git
synced 2025-05-29 16:21:20 +03:00
Fix performance bug in constant-expression simplifier. After finding
that the inputs to a given operator can be recursively simplified to constants, it was evaluating the operator using the op's *original* (unsimplified) arg list, so that any subexpressions had to be evaluated again. A constant subexpression at depth N got evaluated N times. Probably not very important in practical situations, but it made us look real slow in MySQL's 'crashme' test...
This commit is contained in:
parent
ef3386affe
commit
1879175b18
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.60 2000/02/20 21:32:06 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.61 2000/03/12 19:32:06 tgl Exp $
|
||||||
*
|
*
|
||||||
* HISTORY
|
* HISTORY
|
||||||
* AUTHOR DATE MAJOR EVENT
|
* AUTHOR DATE MAJOR EVENT
|
||||||
@ -991,18 +991,26 @@ eval_const_expressions_mutator (Node *node, void *context)
|
|||||||
* duplication of code and ensure we get the same result
|
* duplication of code and ensure we get the same result
|
||||||
* as the executor would get.
|
* as the executor would get.
|
||||||
*
|
*
|
||||||
* The only setup needed here is the replace_opid()
|
* Build a new Expr node containing the already-simplified
|
||||||
* that we already did for the OP_EXPR case.
|
* arguments. The only other setup needed here is the
|
||||||
*
|
* replace_opid() that we already did for the OP_EXPR case.
|
||||||
|
*/
|
||||||
|
newexpr = makeNode(Expr);
|
||||||
|
newexpr->typeOid = expr->typeOid;
|
||||||
|
newexpr->opType = expr->opType;
|
||||||
|
newexpr->oper = expr->oper;
|
||||||
|
newexpr->args = args;
|
||||||
|
/*
|
||||||
* It is OK to pass econtext = NULL because none of the
|
* It is OK to pass econtext = NULL because none of the
|
||||||
* ExecEvalExpr() code used in this situation will use
|
* ExecEvalExpr() code used in this situation will use
|
||||||
* econtext. That might seem fortuitous, but it's not
|
* econtext. That might seem fortuitous, but it's not
|
||||||
* so unreasonable --- a constant expression does not
|
* so unreasonable --- a constant expression does not
|
||||||
* depend on context, by definition, n'est ce pas?
|
* depend on context, by definition, n'est ce pas?
|
||||||
*/
|
*/
|
||||||
const_val = ExecEvalExpr((Node *) expr, NULL,
|
const_val = ExecEvalExpr((Node *) newexpr, NULL,
|
||||||
&const_is_null, &isDone);
|
&const_is_null, &isDone);
|
||||||
Assert(isDone); /* if this isn't set, we blew it... */
|
Assert(isDone); /* if this isn't set, we blew it... */
|
||||||
|
pfree(newexpr);
|
||||||
/*
|
/*
|
||||||
* Make the constant result node.
|
* Make the constant result node.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user