Re: Default setting for enable_hashagg_disk - Mailing list pgsql-hackers
From | Peter Geoghegan |
---|---|
Subject | Re: Default setting for enable_hashagg_disk |
Date | |
Msg-id | CAH2-WzkABYexMiM2nwoViR0g0a+=cmFSp66gXZZmNYEDRaksbg@mail.gmail.com Whole thread Raw |
In response to | Re: Default setting for enable_hashagg_disk (David Rowley <dgrowleyml@gmail.com>) |
Responses |
Re: Default setting for enable_hashagg_disk
|
List | pgsql-hackers |
On Fri, Jul 10, 2020 at 6:19 PM David Rowley <dgrowleyml@gmail.com> wrote: > If we get hash_mem > or some variant that is a multiplier of work_mem, then that user is in > exactly the same situation for that plan. i.e there's no ability to > increase the memory allowances for Hash Agg alone. That's true, of course. > If we have to have a new GUC, my preference would be hashagg_mem, > where -1 means use work_mem and a value between 64 and MAX_KILOBYTES > would mean use that value. We'd need some sort of check hook to > disallow 0-63. I really am just failing to comprehend why we're > contemplating changing the behaviour of Hash Join here. I don't understand why parititonwise hash join consumes work_mem in the way it does. I assume that the reason is something like "because that behavior was the easiest to explain", or perhaps "people that use partitioning ought to be able to tune their database well". Or even "this design avoids an epic pgsql-hackers thread, because of course every hash table should get its own work_mem". > Of course, I > understand that that node type also uses a hash table, but why does > that give it the right to be involved in a change that we're making to > try and give users the ability to avoid possible regressions with Hash > Agg? It doesn't, exactly. The idea of hash_mem came from similar settings in another database system that you'll have heard of, that affect all nodes that use a hash table. I read about this long ago, and thought that it might make sense to do something similar as a way to improving work_mem (without replacing it with something completely different to enable things like the "hash teams" design, which should be the long term goal). It's unusual that it took this hashaggs-that-spill issue to make the work_mem situation come to a head, and it's unusual that the proposal on the table doesn't just target hash agg. But it's not *that* unusual. I believe that it makes sense on balance to lump together hash aggregate and hash join, with the expectation that the user might want to tune them for the system as a whole. This is not an escape hatch -- it's something that adds granularity to how work_mem can be tuned in a way that makes sense (but doesn't make perfect sense). It doesn't reflect reality, but I think that it comes closer to reflecting reality than other variations that I can think of, including your hashagg_mem compromise proposal (which is still much better than plain work_mem). In short, hash_mem is relatively conceptually clean, and doesn't unduly burden the user. I understand that you only want to add an escape hatch, which is what hashagg_mem still amounts to. There are negative consequences to the setting affecting hash join, which I am not unconcerned about. On the other hand, hashagg_mem is an escape hatch, and that's ugly in a way that hash_mem isn't. I'm also concerned about that. In the end, I think that the "hash_mem vs. hashagg_mem" question is fundamentally a matter of opinion. -- Peter Geoghegan
pgsql-hackers by date: