Re: Memory-Bounded Hash Aggregation
Adam Lee <ali@pivotal.io>
> High-level approaches: > > 1. When the in-memory hash table fills, keep existing entries in the > hash table, and spill the raw tuples for all new groups in a > partitioned fashion. When all input tuples are read, finalize groups > in memory and emit. Now that the in-memory hash table is cleared (and > memory context reset), process a spill file the same as the original > input, but this time with a fraction of the group cardinality. > > 2. When the in-memory hash table fills, partition the hash space, and > evict the groups from all partitions except one by writing out their > partial aggregate states to disk. Any input tuples belonging to an > evicted partition get spilled to disk. When the input is read > entirely, finalize the groups remaining in memory and emit. Now that > the in-memory hash table is cleared, process the next partition by > loading its partial states into the hash table, and then processing > its spilled tuples. I'm late to the party. These two approaches both spill the input tuples, what if the skewed groups are not encountered before the hash table fills up? The spill files' size and disk I/O could be downsides. Greenplum spills all the groups by writing the partial aggregate states, reset the memory context, process incoming tuples and build in-memory hash table, then reload and combine the spilled partial states at last, how does this sound? -- Adam Lee
Commits
-
Fix costing for disk-based hash aggregation.
- 7351bfeda33b 13.0 landed
-
Fixes for Disk-based Hash Aggregation.
- 64fe60227909 13.0 landed
-
Disk-based Hash Aggregation.
- 1f39bce02154 13.0 landed
-
Extend ExecBuildAggTrans() to support a NULL pointer check.
- c954d4904650 13.0 landed
-
Save calculated transitionSpace in Agg node.
- c11cb17dc55a 13.0 landed
-
Minor refactor of nodeAgg.c.
- 5b618e1f48ae 13.0 landed
-
Logical Tape Set: lazily allocate read buffer.
- 7fdd919ae755 13.0 landed
-
Introduce TupleHashTableHash() and LookupTupleHashEntryHash().
- 4eaea3db150a 13.0 landed
-
Logical Tape Set: use min heap for freelist.
- c02fdc922301 13.0 landed
-
Fix comments in execGrouping.c
- 30d47723fd15 13.0 landed
-
Avoid integer overflow while sifting-up a heap in tuplesort.c.
- 512f67c8d02c 10.0 cited
-
Make the overflow guards in ExecChooseHashTableSize be more protective.
- 8442317beb8f 9.0.0 cited
-
Improve performance of our private version of qsort. Per recent testing,
- a3f0b3d68f9a 8.2.0 cited