Disk Spilling in a Vectorized Execution Engine
cockroachlabs.com
cockroachlabs.com
Sorting is a good idea. The in-memory aggregator could keep track of the aggregation columns of each bucket, sort the buckets and input that has not yet been processed and then perform an ordered aggregation on the sorted input using the already-computed intermediate result as a starting point for the group's aggregation result.
Another option is to partition the buckets and input, which would subdivide the aggregation and avoid a sort.