why declare arg as a array in FunctionCallInfoData structure
hi,
When I read the postgresql codes, I noticed that the FunctionCallInfoData
structure(declared in the src/include/fmgr.h) contains two arrays 'arg' and
'argnull'.
Why don't you declare it as a pointer and allocate the memory from heap? It
saves more momery if 'arg' and 'argnull' declares as pointer type.
Can anyone explain it to me?
Thanks in advance.
On Mon, Feb 02, 2009 at 03:16:01PM +0800, Tao Ma wrote:
hi,
When I read the postgresql codes, I noticed that the FunctionCallInfoData
structure(declared in the src/include/fmgr.h) contains two arrays 'arg' and
'argnull'.
Why don't you declare it as a pointer and allocate the memory from heap? It
saves more momery if 'arg' and 'argnull' declares as pointer type.
I imagaine it's because most of the time this structure would be
allocated on the stack, where allocation is essentially free. Having to
allocate two arrays from the heap would be slower.
Have a nice day,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/
Show quoted text
Please line up in a tree and maintain the heap invariant while
boarding. Thank you for flying nlogn airlines.
2009/2/2 Tao Ma <feng_eden@163.com>:
hi,
When I read the postgresql codes, I noticed that the FunctionCallInfoData
structure(declared in the src/include/fmgr.h) contains two arrays 'arg' and
'argnull'.
Why don't you declare it as a pointer and allocate the memory from heap? It
saves more momery if 'arg' and 'argnull' declares as pointer type.Can anyone explain it to me?
It based on Datum data type, that store short fixed values directly
(int, float), and you need second array, that carries info about NULL
or NOT NULL. Bigger problem is some non consistency - sometime this is
bool array, and sometime array of char.
Regards
Pavel Stehule
Show quoted text
Thanks in advance.
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
"Tao Ma" <feng_eden@163.com> writes:
When I read the postgresql codes, I noticed that the FunctionCallInfoData
structure(declared in the src/include/fmgr.h) contains two arrays 'arg' and
'argnull'.
Why don't you declare it as a pointer and allocate the memory from
heap?
Speed. We spend enough cycles in palloc already.
regards, tom lane