improves ExecMakeFunctionResultNoSets

Started by Atsushi Ogawaover 21 years ago2 messagespatches
Jump to latest
#1Atsushi Ogawa
a_ogawa@hi-ho.ne.jp

Attached patch improves ExecMakeFunctionResultNoSets, etc.

This patch uses InitFunctionCallInfoData macro instead of MemSet to
initialize FunctionCallInfoData.
An idea of this patch discussed in the "FunctionCallN improvement" thread.
(http://archives.postgresql.org/pgsql-hackers/2005-01/msg01054.php)
To achieve this, InitFunctionCallInfoData macro was moved from fmgr.c to
fmgr.h.

test sql:
select substr(c.relname, 1, 10) from pg_class c, pg_am, pg_amop;
(There are pg_am and pg_amop only to increase the number of the records.)

result of original code:
-----------------------------------------------------------------------
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls s/call s/call name
21.43 0.36 0.36 219911 0.00 0.00
ExecMakeFunctionResultNoSets
7.14 0.48 0.12 219912 0.00 0.00 pg_mbstrlen_with_len
6.25 0.58 0.10 1102916 0.00 0.00 AllocSetAlloc
5.36 0.68 0.09 5936448 0.00 0.00 pg_euc_mblen
5.36 0.77 0.09 5936448 0.00 0.00 pg_mblen

result of after patch:
-----------------------------------------------------------------------
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls s/call s/call name
7.52 0.10 0.10 5936448 0.00 0.00 pg_mblen
7.14 0.20 0.10 1104587 0.00 0.00 AllocSetAlloc
6.77 0.28 0.09 219912 0.00 0.00 text_substring
6.39 0.37 0.09 1547723 0.00 0.00 AllocSetFreeIndex
6.02 0.45 0.08 219912 0.00 0.00 pg_mbstrlen_with_len
4.51 0.51 0.06 5936448 0.00 0.00 pg_euc_mblen
4.51 0.57 0.06 442745 0.00 0.00 ExecProcNode
4.51 0.63 0.06 219911 0.00 0.00
ExecMakeFunctionResultNoSets

regards,

--- Atsushi Ogawa

Attachments:

ExecMakeFunctionResultNoSets.patchapplication/octet-stream; name=ExecMakeFunctionResultNoSets.patchDownload+47-36
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Atsushi Ogawa (#1)
Re: improves ExecMakeFunctionResultNoSets

a_ogawa <a_ogawa@hi-ho.ne.jp> writes:

This patch uses InitFunctionCallInfoData macro instead of MemSet to
initialize FunctionCallInfoData.
An idea of this patch discussed in the "FunctionCallN improvement" thread.
(http://archives.postgresql.org/pgsql-hackers/2005-01/msg01054.php)

Looks good --- applied with minor changes. I figured that if we were
going to make InitFunctionCallInfoData generally available, we had
better fix it to cover initializing the context and resultinfo fields
per caller option. Also cleaned up a couple of other places that
already had hand-optimized calling sequences, and can now be written
more cleanly using the macro. Also, I removed this code you added in
a couple places:

+         /*
+          * argnull is initialized here for safety. Because it might not be
+          * set by ExecEvalExpr. 
+          */
+         fcinfo->argnull[i] = false;

If ExecEvalExpr fails to set its isNull argument we will have breakage
all over; there is no need for speed-critical code to assume it has
to do this.

regards, tom lane