Re: 9.5: Memory-bounded HashAgg - Mailing list pgsql-hackers

From Tomas Vondra
Subject Re: 9.5: Memory-bounded HashAgg
Date
Msg-id 53EBA933.9070704@fuzzy.cz
Whole thread Raw
In response to Re: 9.5: Memory-bounded HashAgg  ("Tomas Vondra" <tv@fuzzy.cz>)
List pgsql-hackers
On 13.8.2014 12:31, Tomas Vondra wrote:
> On 13 Srpen 2014, 7:02, Jeff Davis wrote:
>> On Tue, 2014-08-12 at 14:58 +0200, Tomas Vondra wrote:
>>>
>>>    (b) bad estimate of required memory -> this is common for aggregates
>>>        passing 'internal' state (planner uses some quite high defaults)
>>
>> Maybe some planner hooks? Ideas?
> 
> My plan is to add this to the CREATE AGGREGATE somehow - either as a
> constant parameter (allowing to set a custom constant size) or a callback
> to a 'sizing' function (estimating the size based on number of items,
> average width and ndistinct in the group). In any case, this is
> independent of this patch.

FWIW, the constant parameter is already implemented for 9.4. Adding the
function seems possible - the most difficult part seems to be getting
all the necessary info before count_agg_clauses() is called. For example
now dNumGroups is evaluated after the call (and tuples/group seems like
a useful info for sizing).

While this seems unrelated to the patch discussed here, it's true that:
 (a) good estimate of the memory is important for initial estimate of     batch count
 (b) dynamic increase of batch count alleviates issues from     underestimating the amount of memory necessary for
states


But let's leave this out of scope for the current patch.


regards
Tomas



pgsql-hackers by date:

Previous
From: Claudio Freire
Date:
Subject: Re: jsonb format is pessimal for toast compression
Next
From: Euler Taveira
Date:
Subject: Re: how to implement selectivity injection in postgresql