Re: Memory-Bounded Hash Aggregation
Adam Lee <ali@pivotal.io>
Attachments
- hashagg_spill.sql (text/plain)
On Sat, Dec 14, 2019 at 06:32:25PM +0100, Tomas Vondra wrote: > I've done a bit more testing on this, after resolving a couple of minor > conflicts due to recent commits (rebased version attached). > > In particular, I've made a comparison with different dataset sizes, > group sizes, GUC settings etc. The script and results from two different > machines are available here: > > The script essentially runs a simple grouping query with different > number of rows, groups, work_mem and parallelism settings. There's > nothing particularly magical about it. Nice! > I did run it both on master and patched code, allowing us to compare > results and assess impact of the patch. Overall, the changes are > expected and either neutral or beneficial, i.e. the timing are the same > or faster. > > The number of cases that regressed is fairly small, but sometimes the > regressions are annoyingly large - up to 2x in some cases. Consider for > example this trivial example with 100M rows: I suppose this is because the patch has no costing changes yet. I hacked a little to give hash agg a spilling punish, just some value based on (groups_in_hashtable * num_of_input_tuples)/num_groups_from_planner, it would not choose hash aggregate in this case. However, that punish is wrong, because comparing to the external sort algorithm, hash aggregate has the respilling, which involves even more I/O, especially with a very large number of groups but a very small number of tuples in a single group like the test you did. It would be a challenge. BTW, Jeff, Greenplum has a test for hash agg spill, I modified a little to check how many batches a query uses, it's attached, not sure if it would help. -- 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