Re: Memory-Bounded Hash Aggregation
Jeff Davis <pgsql@j-davis.com>
Attachments
- hashagg-20191220.patch (text/x-patch) patch
On Tue, 2019-12-10 at 13:34 -0800, Adam Lee wrote: > Melanie and I tried this, had a installcheck passed patch. The way > how > we verify it is composing a wide table with long unnecessary text > columns, then check the size it writes on every iteration. > > Please check out the attachment, it's based on your 1204 version. Thank you. Attached a new patch that incorporates your projection work. A few comments: * You are only nulling out up to tts_nvalid, which means that you can still end up storing more on disk if the wide column comes at the end of the table and hasn't been deserialized yet. I fixed this by copying needed attributes to the hash_spill_slot and making it virtual. * aggregated_columns does not need to be a member of AggState; nor does it need to be computed inside of the perhash loop. Aside: if adding a field to AggState is necessary, you need to bump the field numbers of later fields that are labeled for JIT use, otherwise it will break JIT. * I used an array rather than a bitmapset. It makes it easier to find the highest column (to do a slot_getsomeattrs), and it might be a little more efficient for wide tables with mostly useless columns. * Style nitpick: don't mix code and declarations The updated patch also saves the transitionSpace calculation in the Agg node for better hash table size estimating. This is a good way to choose an initial number of buckets for the hash table, and also to cap the number of groups we permit in the hash table when we expect the groups to grow. Regards, Jeff Davis
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