Re: Combining Aggregates

From: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Combining Aggregates
Date: 2016-01-19 05:11:40
Message-ID: 569DC58C.30001@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 01/19/2016 06:04 AM, Tomas Vondra wrote:
> Hi,
>
> On 01/19/2016 05:00 AM, David Rowley wrote:
>> Good question. I looked at this and found my VM was swapping like crazy.
>> Upon investigation it appears that's because, since the patch creates a
>> memory context per aggregated group, and in this case I've got 1 million
>> of them, it means we create 1 million context, which are
>> ALLOCSET_SMALL_INITSIZE (1KB) in size, which means about 1GB of memory,
>> which is more than my VM likes.
>
> Really? Where do we create the memory context? IIRC string_agg uses the
> aggcontext directly, and indeed that's what I see in string_agg_transfn
> and makeStringAggState.
>
> Perhaps you mean that initStringInfo() allocates 1kB buffers by default?

...

> I'm not quite sure I understand - the current code ends up using 8192
> for the transition space (per count_agg_clauses_walker). Are you
> suggesting lowering the value, despite the danger of OOM issues?

Meh, right after sending the message I realized that perhaps this
relates to Robert's patch and that maybe it changes this. And indeed, it
changes the type from internal to text, and thus the special case in
count_agg_clauses_walker no longer applies.

regards

--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2016-01-19 05:16:26 Re: Combining Aggregates
Previous Message Michael Paquier 2016-01-19 05:11:20 Re: Removing service-related code in pg_ctl for Cygwin