Thread: Re: [SQL] OFFSET impact on Performance???

Re: [SQL] OFFSET impact on Performance???

From
"Merlin Moncure"
Date:
Greg Stark wrote:

> test=> create or replace function array_push (anyarray, anyelement)
> returns anyarray as 'select $1 || $2' language sql immutable strict;
> CREATE FUNCTION
> test=> create aggregate array_aggregate (basetype=anyelement,
> sfunc=array_push, stype=anyarray, initcond = '{}');
> CREATE AGGREGATE

what about
CREATE AGGREGATE array_accum (
    sfunc = array_append,
    basetype = anyelement,
    stype = anyarray,
    initcond = '{}'
);
?
Merlin

Re: [SQL] OFFSET impact on Performance???

From
Greg Stark
Date:
"Merlin Moncure" <merlin.moncure@rcsonline.com> writes:

> what about
> CREATE AGGREGATE array_accum (
>     sfunc = array_append,
>     basetype = anyelement,
>     stype = anyarray,
>     initcond = '{}'
> );

huh, that is faster. It's only 14x slower than the C implementation.

For completeness, here are the fastest times I get after repeating a few times
each:

 13.97 ms     contrib/intagg C implementation
194.76 ms     aggregate using array_append
723.15 ms     aggregate with SQL state function

--
greg