I wrote:
> Alvaro Herrera <alvherre@2ndquadrant.com> writes:
>> Tom Lane wrote:
>>> Presumably what is happening is that the planner is switching from hash
>>> to sort aggregation.
>> I can't imagine that the server is avoiding hash aggregation on a 1MB
>> work_mem limit for data that's a few dozen of bytes. Is it really doing
>> that?
> Yup:
I looked more closely and found that the reason it's afraid to use hash
aggregation is the amount of transition space potentially needed by
string_agg. That's being estimated as 8kB per group, and with the
(default) estimate of 200 groups, you get about 1.6MB estimated to be
needed.
Also, I confirmed my suspicion that some other regression tests fail
when you reduce work_mem below 1MB. So I'm not really excited
about changing this one.
regards, tom lane