mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
Replace the switching function ExecEvalExpr() with a macro that jumps
directly to the appropriate per-node execution function, using a function pointer stored by ExecInitExpr. This speeds things up by eliminating one level of function call. The function-pointer technique also enables further small improvements such as only making one-time tests once (and then changing the function pointer). Overall this seems to gain about 10% on evaluation of simple expressions, which isn't earthshaking but seems a worthwhile gain for a relatively small hack. Per recent discussion on pghackers.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeHash.c,v 1.82 2004/02/03 17:34:02 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeHash.c,v 1.83 2004/03/17 01:02:23 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -532,6 +532,7 @@ ExecHashGetBucket(HashJoinTable hashtable,
|
||||
|
||||
foreach(hk, hashkeys)
|
||||
{
|
||||
ExprState *keyexpr = (ExprState *) lfirst(hk);
|
||||
Datum keyval;
|
||||
bool isNull;
|
||||
|
||||
@ -541,8 +542,7 @@ ExecHashGetBucket(HashJoinTable hashtable,
|
||||
/*
|
||||
* Get the join attribute value of the tuple
|
||||
*/
|
||||
keyval = ExecEvalExpr((ExprState *) lfirst(hk),
|
||||
econtext, &isNull, NULL);
|
||||
keyval = ExecEvalExpr(keyexpr, econtext, &isNull, NULL);
|
||||
|
||||
/*
|
||||
* Compute the hash function
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeMergejoin.c,v 1.63 2003/11/29 19:51:48 pgsql Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeMergejoin.c,v 1.64 2004/03/17 01:02:23 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -191,6 +191,8 @@ MergeCompare(List *eqQual, List *compareQual, ExprContext *econtext)
|
||||
eqclause = eqQual;
|
||||
foreach(clause, compareQual)
|
||||
{
|
||||
ExprState *clauseexpr = (ExprState *) lfirst(clause);
|
||||
ExprState *eqclauseexpr = (ExprState *) lfirst(eqclause);
|
||||
Datum const_value;
|
||||
bool isNull;
|
||||
|
||||
@ -200,10 +202,7 @@ MergeCompare(List *eqQual, List *compareQual, ExprContext *econtext)
|
||||
*
|
||||
* A NULL result is considered false.
|
||||
*/
|
||||
const_value = ExecEvalExpr((ExprState *) lfirst(clause),
|
||||
econtext,
|
||||
&isNull,
|
||||
NULL);
|
||||
const_value = ExecEvalExpr(clauseexpr, econtext, &isNull, NULL);
|
||||
|
||||
if (DatumGetBool(const_value) && !isNull)
|
||||
{
|
||||
@ -217,10 +216,7 @@ MergeCompare(List *eqQual, List *compareQual, ExprContext *econtext)
|
||||
* key1 = key2 so we move on to the next pair of keys.
|
||||
*-----------
|
||||
*/
|
||||
const_value = ExecEvalExpr((ExprState *) lfirst(eqclause),
|
||||
econtext,
|
||||
&isNull,
|
||||
NULL);
|
||||
const_value = ExecEvalExpr(eqclauseexpr, econtext, &isNull, NULL);
|
||||
|
||||
if (!DatumGetBool(const_value) || isNull)
|
||||
break; /* return false */
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeSubplan.c,v 1.60 2004/01/14 23:01:54 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeSubplan.c,v 1.61 2004/03/17 01:02:23 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -47,10 +47,16 @@ static bool tupleAllNulls(HeapTuple tuple);
|
||||
Datum
|
||||
ExecSubPlan(SubPlanState *node,
|
||||
ExprContext *econtext,
|
||||
bool *isNull)
|
||||
bool *isNull,
|
||||
ExprDoneCond *isDone)
|
||||
{
|
||||
SubPlan *subplan = (SubPlan *) node->xprstate.expr;
|
||||
|
||||
/* Set default values for result flags: non-null, not a set result */
|
||||
*isNull = false;
|
||||
if (isDone)
|
||||
*isDone = ExprSingleResult;
|
||||
|
||||
if (subplan->setParam != NIL)
|
||||
elog(ERROR, "cannot set parent params from subquery");
|
||||
|
||||
@ -819,6 +825,7 @@ ExecInitSubPlan(SubPlanState *node, EState *estate)
|
||||
expr);
|
||||
tlestate = makeNode(GenericExprState);
|
||||
tlestate->xprstate.expr = (Expr *) tle;
|
||||
tlestate->xprstate.evalfunc = NULL;
|
||||
tlestate->arg = exstate;
|
||||
lefttlist = lappend(lefttlist, tlestate);
|
||||
leftptlist = lappend(leftptlist, tle);
|
||||
@ -834,6 +841,7 @@ ExecInitSubPlan(SubPlanState *node, EState *estate)
|
||||
expr);
|
||||
tlestate = makeNode(GenericExprState);
|
||||
tlestate->xprstate.expr = (Expr *) tle;
|
||||
tlestate->xprstate.evalfunc = NULL;
|
||||
tlestate->arg = exstate;
|
||||
righttlist = lappend(righttlist, tlestate);
|
||||
rightptlist = lappend(rightptlist, tle);
|
||||
|
Reference in New Issue
Block a user