Hannu Krosing <hannu@tm.ee> writes:
> OTOH, I'm not sure if hash aggregates can already spill to disk if not
> enough memory is available for keeping them all.
They do not, which is something it'd be good to fix, since if the
planner drastically underestimates the number of groups, you could end
up with a hashtable far bigger than the advertised SortMem. Even if
this doesn't end up with an "out of memory" error, it could still drive
you into swap hell.
(Maybe that should be Robert's get-your-feet-wet project.)
regards, tom lane