Re: OLAP, Aggregates, and order of operations - Mailing list pgsql-hackers

From Tom Lane
Subject Re: OLAP, Aggregates, and order of operations
Date
Msg-id 8897.998594345@sss.pgh.pa.us
Whole thread Raw
In response to OLAP, Aggregates, and order of operations  (mlw <markw@mohawksoft.com>)
List pgsql-hackers
mlw <markw@mohawksoft.com> writes:
>> If the needed parameters are all the same datatype, maybe you could put
>> them into an array and pass the array as a single argument to the
>> aggregate.

> How would you do this without having to make multiple SQL calls?

I was thinking something like
   select my_aggregate(my_array_constructor(foo, bar, baz)) from ...

where my_array_constructor is a quick hack C routine to build a
3-element array from 3 input arguments (s/3/whatever you need/).
Someday we ought to have SQL syntax to build an array value from
a list of scalars, but in the meantime an auxiliary function is the
only way to do it.

The overhead of constructing and then interpreting the temporary
array value is slightly annoying, but I don't think it'll be horribly
expensive.  See the existing aggregate-related routines in numeric.c
if you need some help with the C coding.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [JDBC] New backend functions? [was Re: JDBC changes for 7.2... some questions...]
Next
From: Peter Eisentraut
Date:
Subject: Remove --enable-syslog?