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:
The reason for that turns out to be that we deliberately lobotomized
array_agg that way, just last month:
in response to this problem:
We need a better idea.
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.
Another possibility is to modify array_agg (and other aggregates that
try to use aggcontext) so that they distinguish hash- and group-mode
aggregation. If we had array_agg attach its working context to the Agg
node's per-output-tuple context instead of aggcontext when in group
mode, I think everything would work as desired. The main disadvantage
of this is modifying a coding convention that third-party code probably
is using. (But OTOH, we have already required any such code to change
I haven't tested either of the above ideas --- just brainstorming
at this point.
Comments, better ideas?
regards, tom lane
pgsql-hackers by date
|Next:||From: Jeff Davis||Date: 2009-07-22 21:26:06|
|Subject: Re: Aggregate-function space leakage|
|Previous:||From: Robert Haas||Date: 2009-07-22 20:11:59|
|Subject: Re: extension facility (was: revised hstore patch)|