Re: [HACKERS] Aggregate-function space leakage

2009-07-24 Thread Hitoshi Harada
2009/7/24 Tom Lane t...@sss.pgh.pa.us: 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

Re: [HACKERS] Aggregate-function space leakage

2009-07-23 Thread Hitoshi Harada
2009/7/23 Greg Stark gsst...@mit.edu: On Wed, Jul 22, 2009 at 10:14 PM, Tom Lanet...@sss.pgh.pa.us 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

Re: [HACKERS] Aggregate-function space leakage

2009-07-23 Thread Tom Lane
Hitoshi Harada umi.tan...@gmail.com 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

Re: [HACKERS] Aggregate-function space leakage

2009-07-23 Thread Tom Lane
Greg Stark gsst...@mit.edu 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

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

[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

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. Is

Re: [HACKERS] Aggregate-function space leakage

2009-07-22 Thread Tom Lane
Jeff Davis pg...@j-davis.com 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

Re: [HACKERS] Aggregate-function space leakage

2009-07-22 Thread Greg Stark
On Wed, Jul 22, 2009 at 10:14 PM, Tom Lanet...@sss.pgh.pa.us 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: