postgres.git / summary / log / commit / refs
commit 37e0a016547abb3526b685d7aacbd0a4d57f6937
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: Thu Oct 28 17:29:13 2010 +0000
First released in: 9.1.0
Save a few cycles in plpgsql simple-expression initialization.
Instead of using ExecPrepareExpr, call ExecInitExpr. The net change here
is that we don't apply expression_planner() to the expression tree. There
is no need to do so, because that tree is extracted from a fully planned
plancache entry, so all the needed work is already done. This reduces
the setup costs by about a factor of 2 according to some simple tests.
Oversight noted while fooling around with the simple-expression code for
previous fix.
src/pl/plpgsql/src/pl_exec.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c
index 1f40f3cf692..4e9afd360b1 100644
--- a/src/pl/plpgsql/src/pl_exec.c
+++ b/src/pl/plpgsql/src/pl_exec.c
@@ -4577,10 +4577,11 @@ exec_eval_simple_expr(PLpgSQL_execstate *estate,
*/
if (expr->expr_simple_lxid != curlxid)
{
- expr->expr_simple_state = ExecPrepareExpr(expr->expr_simple_expr,
- simple_eval_estate);
+ oldcontext = MemoryContextSwitchTo(simple_eval_estate->es_query_cxt);
+ expr->expr_simple_state = ExecInitExpr(expr->expr_simple_expr, NULL);
expr->expr_simple_in_use = false;
expr->expr_simple_lxid = curlxid;
+ MemoryContextSwitchTo(oldcontext);
}
/*
[parent: 8ce22dd4c51b]