mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +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:
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/nodes/execnodes.h,v 1.112 2004/02/28 19:46:06 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/include/nodes/execnodes.h,v 1.113 2004/03/17 01:02:24 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -390,13 +390,25 @@ typedef HASH_SEQ_STATUS TupleHashIterator;
|
||||
*
|
||||
* It can also be instantiated directly for leaf Expr nodes that need no
|
||||
* local run-time state (such as Var, Const, or Param).
|
||||
*
|
||||
* To save on dispatch overhead, each ExprState node contains a function
|
||||
* pointer to the routine to execute to evaluate the node.
|
||||
* ----------------
|
||||
*/
|
||||
typedef struct ExprState
|
||||
|
||||
typedef struct ExprState ExprState;
|
||||
|
||||
typedef Datum (*ExprStateEvalFunc) (ExprState *expression,
|
||||
ExprContext *econtext,
|
||||
bool *isNull,
|
||||
ExprDoneCond *isDone);
|
||||
|
||||
struct ExprState
|
||||
{
|
||||
NodeTag type;
|
||||
Expr *expr; /* associated Expr node */
|
||||
} ExprState;
|
||||
ExprStateEvalFunc evalfunc; /* routine to run to execute node */
|
||||
};
|
||||
|
||||
/* ----------------
|
||||
* GenericExprState node
|
||||
|
Reference in New Issue
Block a user