Commit 6342f36d authored by Tom Lane's avatar Tom Lane

Save one syscache lookup when examining volatility or strictness of

OpExpr and related nodes.  We're going to have to set the opfuncid of
such nodes eventually (if we haven't already), so we might as well
exploit the opportunity to cache the function OID.  Buys back some
of the extra planner overhead noted by Guillaume Smet, though I still
need to fool with equivclass.c to really respond to that.
parent b85cf684
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.251 2007/11/15 21:14:36 momjian Exp $ * $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.252 2007/11/22 19:09:23 tgl Exp $
* *
* HISTORY * HISTORY
* AUTHOR DATE MAJOR EVENT * AUTHOR DATE MAJOR EVENT
...@@ -715,7 +715,8 @@ contain_mutable_functions_walker(Node *node, void *context) ...@@ -715,7 +715,8 @@ contain_mutable_functions_walker(Node *node, void *context)
{ {
OpExpr *expr = (OpExpr *) node; OpExpr *expr = (OpExpr *) node;
if (op_volatile(expr->opno) != PROVOLATILE_IMMUTABLE) set_opfuncid(expr);
if (func_volatile(expr->opfuncid) != PROVOLATILE_IMMUTABLE)
return true; return true;
/* else fall through to check args */ /* else fall through to check args */
} }
...@@ -723,7 +724,8 @@ contain_mutable_functions_walker(Node *node, void *context) ...@@ -723,7 +724,8 @@ contain_mutable_functions_walker(Node *node, void *context)
{ {
DistinctExpr *expr = (DistinctExpr *) node; DistinctExpr *expr = (DistinctExpr *) node;
if (op_volatile(expr->opno) != PROVOLATILE_IMMUTABLE) set_opfuncid((OpExpr *) expr); /* rely on struct equivalence */
if (func_volatile(expr->opfuncid) != PROVOLATILE_IMMUTABLE)
return true; return true;
/* else fall through to check args */ /* else fall through to check args */
} }
...@@ -731,7 +733,8 @@ contain_mutable_functions_walker(Node *node, void *context) ...@@ -731,7 +733,8 @@ contain_mutable_functions_walker(Node *node, void *context)
{ {
ScalarArrayOpExpr *expr = (ScalarArrayOpExpr *) node; ScalarArrayOpExpr *expr = (ScalarArrayOpExpr *) node;
if (op_volatile(expr->opno) != PROVOLATILE_IMMUTABLE) set_sa_opfuncid(expr);
if (func_volatile(expr->opfuncid) != PROVOLATILE_IMMUTABLE)
return true; return true;
/* else fall through to check args */ /* else fall through to check args */
} }
...@@ -767,7 +770,8 @@ contain_mutable_functions_walker(Node *node, void *context) ...@@ -767,7 +770,8 @@ contain_mutable_functions_walker(Node *node, void *context)
{ {
NullIfExpr *expr = (NullIfExpr *) node; NullIfExpr *expr = (NullIfExpr *) node;
if (op_volatile(expr->opno) != PROVOLATILE_IMMUTABLE) set_opfuncid((OpExpr *) expr); /* rely on struct equivalence */
if (func_volatile(expr->opfuncid) != PROVOLATILE_IMMUTABLE)
return true; return true;
/* else fall through to check args */ /* else fall through to check args */
} }
...@@ -826,7 +830,8 @@ contain_volatile_functions_walker(Node *node, void *context) ...@@ -826,7 +830,8 @@ contain_volatile_functions_walker(Node *node, void *context)
{ {
OpExpr *expr = (OpExpr *) node; OpExpr *expr = (OpExpr *) node;
if (op_volatile(expr->opno) == PROVOLATILE_VOLATILE) set_opfuncid(expr);
if (func_volatile(expr->opfuncid) == PROVOLATILE_VOLATILE)
return true; return true;
/* else fall through to check args */ /* else fall through to check args */
} }
...@@ -834,7 +839,8 @@ contain_volatile_functions_walker(Node *node, void *context) ...@@ -834,7 +839,8 @@ contain_volatile_functions_walker(Node *node, void *context)
{ {
DistinctExpr *expr = (DistinctExpr *) node; DistinctExpr *expr = (DistinctExpr *) node;
if (op_volatile(expr->opno) == PROVOLATILE_VOLATILE) set_opfuncid((OpExpr *) expr); /* rely on struct equivalence */
if (func_volatile(expr->opfuncid) == PROVOLATILE_VOLATILE)
return true; return true;
/* else fall through to check args */ /* else fall through to check args */
} }
...@@ -842,7 +848,8 @@ contain_volatile_functions_walker(Node *node, void *context) ...@@ -842,7 +848,8 @@ contain_volatile_functions_walker(Node *node, void *context)
{ {
ScalarArrayOpExpr *expr = (ScalarArrayOpExpr *) node; ScalarArrayOpExpr *expr = (ScalarArrayOpExpr *) node;
if (op_volatile(expr->opno) == PROVOLATILE_VOLATILE) set_sa_opfuncid(expr);
if (func_volatile(expr->opfuncid) == PROVOLATILE_VOLATILE)
return true; return true;
/* else fall through to check args */ /* else fall through to check args */
} }
...@@ -878,7 +885,8 @@ contain_volatile_functions_walker(Node *node, void *context) ...@@ -878,7 +885,8 @@ contain_volatile_functions_walker(Node *node, void *context)
{ {
NullIfExpr *expr = (NullIfExpr *) node; NullIfExpr *expr = (NullIfExpr *) node;
if (op_volatile(expr->opno) == PROVOLATILE_VOLATILE) set_opfuncid((OpExpr *) expr); /* rely on struct equivalence */
if (func_volatile(expr->opfuncid) == PROVOLATILE_VOLATILE)
return true; return true;
/* else fall through to check args */ /* else fall through to check args */
} }
...@@ -951,7 +959,8 @@ contain_nonstrict_functions_walker(Node *node, void *context) ...@@ -951,7 +959,8 @@ contain_nonstrict_functions_walker(Node *node, void *context)
{ {
OpExpr *expr = (OpExpr *) node; OpExpr *expr = (OpExpr *) node;
if (!op_strict(expr->opno)) set_opfuncid(expr);
if (!func_strict(expr->opfuncid))
return true; return true;
/* else fall through to check args */ /* else fall through to check args */
} }
...@@ -1091,7 +1100,8 @@ find_nonnullable_rels_walker(Node *node, bool top_level) ...@@ -1091,7 +1100,8 @@ find_nonnullable_rels_walker(Node *node, bool top_level)
{ {
OpExpr *expr = (OpExpr *) node; OpExpr *expr = (OpExpr *) node;
if (op_strict(expr->opno)) set_opfuncid(expr);
if (func_strict(expr->opfuncid))
result = find_nonnullable_rels_walker((Node *) expr->args, false); result = find_nonnullable_rels_walker((Node *) expr->args, false);
} }
else if (IsA(node, ScalarArrayOpExpr)) else if (IsA(node, ScalarArrayOpExpr))
...@@ -1228,7 +1238,8 @@ is_strict_saop(ScalarArrayOpExpr *expr, bool falseOK) ...@@ -1228,7 +1238,8 @@ is_strict_saop(ScalarArrayOpExpr *expr, bool falseOK)
Node *rightop; Node *rightop;
/* The contained operator must be strict. */ /* The contained operator must be strict. */
if (!op_strict(expr->opno)) set_sa_opfuncid(expr);
if (!func_strict(expr->opfuncid))
return false; return false;
/* If ANY and falseOK, that's all we need to check. */ /* If ANY and falseOK, that's all we need to check. */
if (expr->useOr && falseOK) if (expr->useOr && falseOK)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment