Hitoshi Harada <umi.tanuki@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 agree that the second choice would be a pain. I think you are
overestimating the cost of the first choice though. We have already
taken steps to ensure that MemoryContextReset is *extremely* cheap
when there is nothing for it to do. If there is something for it to
do, well, that's the case that we have a memory leak now. Also,
resetting the context should be cheaper than retail pfree's anyway.
Anyway, I'll go take a look at exactly what would be involved in the
first choice.
regards, tom lane