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
ExecMakeFunctionResultNoSets.patch
Description: Binary data
---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match