summaryrefslogtreecommitdiff
path: root/src/backend/utils/fmgr/fmgr.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-10-04 17:19:55 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-10-04 17:19:55 +0000
commit3b8ba163d0511a238971c165ffeeb9abdeaceb7c (patch)
treea31dd62f5407aa470144c0466508cb80a1563646 /src/backend/utils/fmgr/fmgr.c
parent53c5edace83616d34e5025841c22b2106aa1aaf0 (diff)
downloadpostgresql-3b8ba163d0511a238971c165ffeeb9abdeaceb7c.tar.gz
Tweak a few of the most heavily used function call points to zero out
just the significant fields of FunctionCallInfoData, rather than MemSet'ing the whole struct to zero. Unused positions in the arg[] array will thereby contain garbage rather than zeroes. This buys back some of the performance hit from increasing FUNC_MAX_ARGS. Also tweak tuplesort.c code for more speed by marking some routines 'inline'. All together these changes speed up simple sorts, like count(distinct int4column), by about 25% on a P4 running RH Linux 7.2.
Diffstat (limited to 'src/backend/utils/fmgr/fmgr.c')
-rw-r--r--src/backend/utils/fmgr/fmgr.c42
1 files changed, 37 insertions, 5 deletions
diff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.c
index c0cef75e8c..470d4a11dd 100644
--- a/src/backend/utils/fmgr/fmgr.c
+++ b/src/backend/utils/fmgr/fmgr.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.62 2002/09/04 20:31:30 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.63 2002/10/04 17:19:55 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -689,6 +689,14 @@ fmgr_security_definer(PG_FUNCTION_ARGS)
/*-------------------------------------------------------------------------
* Support routines for callers of fmgr-compatible functions
+ *
+ * NOTE: the simplest way to reliably initialize a FunctionCallInfoData
+ * is to MemSet it to zeroes and then fill in the fields that should be
+ * nonzero. However, in a few of the most heavily used paths, we instead
+ * just zero the fields that must be zero. This saves a fair number of
+ * cycles so it's worth the extra maintenance effort. Also see inlined
+ * version of FunctionCall2 in utils/sort/tuplesort.c if you need to change
+ * these routines!
*-------------------------------------------------------------------------
*/
@@ -703,9 +711,15 @@ DirectFunctionCall1(PGFunction func, Datum arg1)
FunctionCallInfoData fcinfo;
Datum result;
- MemSet(&fcinfo, 0, sizeof(fcinfo));
+ /* MemSet(&fcinfo, 0, sizeof(fcinfo)); */
+ fcinfo.flinfo = NULL;
+ fcinfo.context = NULL;
+ fcinfo.resultinfo = NULL;
+ fcinfo.isnull = false;
+
fcinfo.nargs = 1;
fcinfo.arg[0] = arg1;
+ fcinfo.argnull[0] = false;
result = (*func) (&fcinfo);
@@ -723,10 +737,17 @@ DirectFunctionCall2(PGFunction func, Datum arg1, Datum arg2)
FunctionCallInfoData fcinfo;
Datum result;
- MemSet(&fcinfo, 0, sizeof(fcinfo));
+ /* MemSet(&fcinfo, 0, sizeof(fcinfo)); */
+ fcinfo.flinfo = NULL;
+ fcinfo.context = NULL;
+ fcinfo.resultinfo = NULL;
+ fcinfo.isnull = false;
+
fcinfo.nargs = 2;
fcinfo.arg[0] = arg1;
fcinfo.arg[1] = arg2;
+ fcinfo.argnull[0] = false;
+ fcinfo.argnull[1] = false;
result = (*func) (&fcinfo);
@@ -936,10 +957,15 @@ FunctionCall1(FmgrInfo *flinfo, Datum arg1)
FunctionCallInfoData fcinfo;
Datum result;
- MemSet(&fcinfo, 0, sizeof(fcinfo));
+ /* MemSet(&fcinfo, 0, sizeof(fcinfo)); */
+ fcinfo.context = NULL;
+ fcinfo.resultinfo = NULL;
+ fcinfo.isnull = false;
+
fcinfo.flinfo = flinfo;
fcinfo.nargs = 1;
fcinfo.arg[0] = arg1;
+ fcinfo.argnull[0] = false;
result = FunctionCallInvoke(&fcinfo);
@@ -957,11 +983,17 @@ FunctionCall2(FmgrInfo *flinfo, Datum arg1, Datum arg2)
FunctionCallInfoData fcinfo;
Datum result;
- MemSet(&fcinfo, 0, sizeof(fcinfo));
+ /* MemSet(&fcinfo, 0, sizeof(fcinfo)); */
+ fcinfo.context = NULL;
+ fcinfo.resultinfo = NULL;
+ fcinfo.isnull = false;
+
fcinfo.flinfo = flinfo;
fcinfo.nargs = 2;
fcinfo.arg[0] = arg1;
fcinfo.arg[1] = arg2;
+ fcinfo.argnull[0] = false;
+ fcinfo.argnull[1] = false;
result = FunctionCallInvoke(&fcinfo);