Re: [HACKERS] Passing "direct" args of ordered-set aggs to the transition function

2014-01-23 Thread Florian Pflug
On Jan23, 2014, at 17:20 , Tom Lane  wrote:
> Florian Pflug  writes:
>> Is there a particular reason why the "direct" arguments of ordered-set
>> aggregates are not passed to the transition function too?
> 
> Because they have to be evaluated only once.
> 
> I did consider evaluating them once at the start and saving the values,
> but that's a bit problematic from a memory management standpoint.

Yeah, that's what I had in mind. I not sure I understand that memory
management problems you mention though - couldn't we just copy them to
some appropriate memory context, say aggcontext?

What I'm more concerned about is whether it'd still be possible to have
ordered_set_transition and ordered_set_transition_multi work for all the
ordered-set aggregates we currently have. But I have yet to wrap my head
fully around the VARIADIC any ANY stuff that goes on there...

> Still, if you have a good solution to that and the cycles to produce a
> patch, it's not too late to reconsider.  I concur that it's not that
> hard to think of cases where it'd be useful.

I'll see what I can do.

best regards,
Florian Pflug



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


Re: [HACKERS] Passing "direct" args of ordered-set aggs to the transition function

2014-01-23 Thread Tom Lane
Florian Pflug  writes:
> Is there a particular reason why the "direct" arguments of ordered-set
> aggregates are not passed to the transition function too?

Because they have to be evaluated only once.

I did consider evaluating them once at the start and saving the values,
but that's a bit problematic from a memory management standpoint.

Still, if you have a good solution to that and the cycles to produce a
patch, it's not too late to reconsider.  I concur that it's not that
hard to think of cases where it'd be useful.

regards, tom lane


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


[HACKERS] Passing "direct" args of ordered-set aggs to the transition function

2014-01-23 Thread Florian Pflug
Hi,

Is there a particular reason why the "direct" arguments of ordered-set
aggregates are not passed to the transition function too? It seems that
evaluating of some ordered-set aggregates would be much cheaper if we did
that.

For example, dense_rank() would then just need to count the number of rows
smaller than the hypothetical row, AFAICS.

Another example (that we don't currently provide, but still) would be a
histogram aggregate which receives an array of buckets as direct args and
returns a similarly shaped array of counters.

best regards,
Florian Pflug



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