For many aggregate functions it is necessary to store the actual column values 
in the aggregate state and then do whatever calculation across them in the 
final function.  In many examples this is done by using array_append as the 
sfunc and then a custom plpgsql function as the final function operating on the 
array.  Unfortunately array_append allocates a new array on each call which 
makes it unusably slow for any large aggregates.

The speed of allocating an array is largely fixed by using array_agg_transfn as 
the state function and a custom C function as the final function,  however this 
requires writing/compiling/packaging the aggregate as an extension written in C 
when often the final function does very simple operations on the array that 
could easily be expressed in a higher level language for convenience.

>From what I can tell ArrayBuildState is defined as type internal because it is 
>a pointer being passed by value.  Is this in fact the limitation that requires 
>it to be type 'internal' or is there another limitation?  Is there someway to 
>expose ArrayBuildState as a type or even another way to do a 'fast' array 
>collection of an aggregate that is to be operated on by a final function 
>written in sql or any of the pl-languages?

Thanks
Dave Byrne


NOTICE: This message and any attachments are intended only for the use of the 
addressee and may contain confidential, proprietary and/or privileged 
information. If you are not the intended recipient, any review, use, 
distribution, dissemination or copying of this email is prohibited. If you have 
received this email in error, please notify the sender by replying to this 
message and delete this email immediately. Securities trading, account 
management, and investment banking services are offered by MDB Capital Group 
LLC, a registered broker-dealer and member of FINRA and SIPC. Unless clearly 
stated, nothing herein shall be construed to be an offer to sell, nor a 
solicitation of an offer to buy, any financial product.


-- 
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to