Re: [HACKERS] Aggregate-function space leakage

2009-07-24 Thread Hitoshi Harada
2009/7/24 Tom Lane : > I think that WindowAgg does not need any changes because it already does > MemoryContextResetAndDeleteChildren(winstate->wincontext) at partition > boundaries.  Hitoshi, do you agree? > I do. Looking closer, temporal space management of Agg is getting similar to WindowAgg's

Re: [HACKERS] Aggregate-function space leakage

2009-07-23 Thread Tom Lane
I wrote: > Anyway, I'll go take a look at exactly what would be involved in the > first choice. Actually, it seems this way results in a net *savings* of code, because we can simply remove the code that was responsible for retail pfree'ing of the transition values. I suppose that code must have p

Re: [HACKERS] Aggregate-function space leakage

2009-07-23 Thread Tom Lane
Greg Stark writes: > Rereading your diagnosis of Merlin Moncure's original problem I'm a > bit puzzled. Why do we have to rerun the final function when we rescan > the hash table? Surely the logical thing to do is to store the final > value in the hash table with some flag saying that value has be

Re: [HACKERS] Aggregate-function space leakage

2009-07-23 Thread Tom Lane
Hitoshi Harada writes: > So two ideas from Tom seem to me a little worse than that. Modifying > Agg.c might add overhead to reset context group by group and forcing > array_agg() (i.e. user aggregates) to distinguish hash-mode and > group-mode is definitely heavy for users. I agree that the secon

Re: [HACKERS] Aggregate-function space leakage

2009-07-23 Thread Hitoshi Harada
2009/7/23 Greg Stark : > On Wed, Jul 22, 2009 at 10:14 PM, Tom Lane wrote: >> The reason for that turns out to be that we deliberately lobotomized >> array_agg that way, just last month: >> http://archives.postgresql.org/pgsql-committers/2009-06/msg00259.php >> in response to this problem: >> http:

Re: [HACKERS] Aggregate-function space leakage

2009-07-22 Thread Greg Stark
On Wed, Jul 22, 2009 at 10:14 PM, Tom Lane wrote: > The reason for that turns out to be that we deliberately lobotomized > array_agg that way, just last month: > http://archives.postgresql.org/pgsql-committers/2009-06/msg00259.php > in response to this problem: > http://archives.postgresql.org/pgsq

Re: [HACKERS] Aggregate-function space leakage

2009-07-22 Thread Tom Lane
Jeff Davis writes: > On Wed, 2009-07-22 at 17:14 -0400, Tom Lane wrote: >> One possibility is to have nodeAgg.c reset the "aggcontext" between >> groups when in group mode. I think this would be more than a one-liner >> fix because it probably has pointers to transvalues that are in that >> conte

Re: [HACKERS] Aggregate-function space leakage

2009-07-22 Thread Jeff Davis
On Wed, 2009-07-22 at 17:14 -0400, Tom Lane wrote: > One possibility is to have nodeAgg.c reset the "aggcontext" between > groups when in group mode. I think this would be more than a one-liner > fix because it probably has pointers to transvalues that are in that > context, but it's surely doable

[HACKERS] Aggregate-function space leakage

2009-07-22 Thread Tom Lane
I looked into Chris Spotts' recent report of massive memory leakage in 8.4, in a case involving array_agg() executed in a GROUP BY query: http://archives.postgresql.org/pgsql-general/2009-07/msg00858.php The reason for that turns out to be that we deliberately lobotomized array_agg that way, just l