Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 6342f36

Browse files
committed
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.
1 parent b85cf68 commit 6342f36

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

src/backend/optimizer/util/clauses.c

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.251 2007/11/15 21:14:36 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.252 2007/11/22 19:09:23 tgl Exp $
1212
*
1313
* HISTORY
1414
* AUTHOR DATE MAJOR EVENT
@@ -715,23 +715,26 @@ contain_mutable_functions_walker(Node *node, void *context)
715715
{
716716
OpExpr *expr = (OpExpr *) node;
717717

718-
if (op_volatile(expr->opno) != PROVOLATILE_IMMUTABLE)
718+
set_opfuncid(expr);
719+
if (func_volatile(expr->opfuncid) != PROVOLATILE_IMMUTABLE)
719720
return true;
720721
/* else fall through to check args */
721722
}
722723
else if (IsA(node, DistinctExpr))
723724
{
724725
DistinctExpr *expr = (DistinctExpr *) node;
725726

726-
if (op_volatile(expr->opno) != PROVOLATILE_IMMUTABLE)
727+
set_opfuncid((OpExpr *) expr); /* rely on struct equivalence */
728+
if (func_volatile(expr->opfuncid) != PROVOLATILE_IMMUTABLE)
727729
return true;
728730
/* else fall through to check args */
729731
}
730732
else if (IsA(node, ScalarArrayOpExpr))
731733
{
732734
ScalarArrayOpExpr *expr = (ScalarArrayOpExpr *) node;
733735

734-
if (op_volatile(expr->opno) != PROVOLATILE_IMMUTABLE)
736+
set_sa_opfuncid(expr);
737+
if (func_volatile(expr->opfuncid) != PROVOLATILE_IMMUTABLE)
735738
return true;
736739
/* else fall through to check args */
737740
}
@@ -767,7 +770,8 @@ contain_mutable_functions_walker(Node *node, void *context)
767770
{
768771
NullIfExpr *expr = (NullIfExpr *) node;
769772

770-
if (op_volatile(expr->opno) != PROVOLATILE_IMMUTABLE)
773+
set_opfuncid((OpExpr *) expr); /* rely on struct equivalence */
774+
if (func_volatile(expr->opfuncid) != PROVOLATILE_IMMUTABLE)
771775
return true;
772776
/* else fall through to check args */
773777
}
@@ -826,23 +830,26 @@ contain_volatile_functions_walker(Node *node, void *context)
826830
{
827831
OpExpr *expr = (OpExpr *) node;
828832

829-
if (op_volatile(expr->opno) == PROVOLATILE_VOLATILE)
833+
set_opfuncid(expr);
834+
if (func_volatile(expr->opfuncid) == PROVOLATILE_VOLATILE)
830835
return true;
831836
/* else fall through to check args */
832837
}
833838
else if (IsA(node, DistinctExpr))
834839
{
835840
DistinctExpr *expr = (DistinctExpr *) node;
836841

837-
if (op_volatile(expr->opno) == PROVOLATILE_VOLATILE)
842+
set_opfuncid((OpExpr *) expr); /* rely on struct equivalence */
843+
if (func_volatile(expr->opfuncid) == PROVOLATILE_VOLATILE)
838844
return true;
839845
/* else fall through to check args */
840846
}
841847
else if (IsA(node, ScalarArrayOpExpr))
842848
{
843849
ScalarArrayOpExpr *expr = (ScalarArrayOpExpr *) node;
844850

845-
if (op_volatile(expr->opno) == PROVOLATILE_VOLATILE)
851+
set_sa_opfuncid(expr);
852+
if (func_volatile(expr->opfuncid) == PROVOLATILE_VOLATILE)
846853
return true;
847854
/* else fall through to check args */
848855
}
@@ -878,7 +885,8 @@ contain_volatile_functions_walker(Node *node, void *context)
878885
{
879886
NullIfExpr *expr = (NullIfExpr *) node;
880887

881-
if (op_volatile(expr->opno) == PROVOLATILE_VOLATILE)
888+
set_opfuncid((OpExpr *) expr); /* rely on struct equivalence */
889+
if (func_volatile(expr->opfuncid) == PROVOLATILE_VOLATILE)
882890
return true;
883891
/* else fall through to check args */
884892
}
@@ -951,7 +959,8 @@ contain_nonstrict_functions_walker(Node *node, void *context)
951959
{
952960
OpExpr *expr = (OpExpr *) node;
953961

954-
if (!op_strict(expr->opno))
962+
set_opfuncid(expr);
963+
if (!func_strict(expr->opfuncid))
955964
return true;
956965
/* else fall through to check args */
957966
}
@@ -1091,7 +1100,8 @@ find_nonnullable_rels_walker(Node *node, bool top_level)
10911100
{
10921101
OpExpr *expr = (OpExpr *) node;
10931102

1094-
if (op_strict(expr->opno))
1103+
set_opfuncid(expr);
1104+
if (func_strict(expr->opfuncid))
10951105
result = find_nonnullable_rels_walker((Node *) expr->args, false);
10961106
}
10971107
else if (IsA(node, ScalarArrayOpExpr))
@@ -1228,7 +1238,8 @@ is_strict_saop(ScalarArrayOpExpr *expr, bool falseOK)
12281238
Node *rightop;
12291239

12301240
/* The contained operator must be strict. */
1231-
if (!op_strict(expr->opno))
1241+
set_sa_opfuncid(expr);
1242+
if (!func_strict(expr->opfuncid))
12321243
return false;
12331244
/* If ANY and falseOK, that's all we need to check. */
12341245
if (expr->useOr && falseOK)

0 commit comments

Comments
 (0)