News for hackers. Stuff that matters.
Re:Postgres Count Performance by life_is_short on Tuesday October 18, 2016 @01:21PM (#12736687)
> for aggregates with variable-length per-group state, we don't have a good size estimate

Can you say a bit more why?

Re:Postgres Count Performance by pgaddict on Tuesday October 18, 2016 @01:56PM (#12737010)
No one implemented a better solution ;-)

Jokes aside, it seems simple but is fairly tricky, as it depends both on input data and various other parameters. For example for array_agg() or string_agg() it might be estimated from number of entries / average length. For hll it also depends on the accuracy and expected number of values to track, etc. I was considering adding another method to the API, providing a better estimate, but never got to that.

So the current code simply assumes 1KB (IIRC) per group in those cases, or something like that.

Of course, the memory estimate also depends on the number of groups, but that's an orthogonal issue.