Re: Default setting for enable_hashagg_disk
Robert Haas <robertmhaas@gmail.com>
From: Robert Haas <robertmhaas@gmail.com>
To: Bruce Momjian <bruce@momjian.us>
Cc: Andres Freund <andres@anarazel.de>, David Rowley <dgrowleyml@gmail.com>, Jeff Davis <pgsql@j-davis.com>, Justin Pryzby <pryzby@telsasoft.com>, Melanie Plageman <melanieplageman@gmail.com>,
Tomas Vondra <tomas.vondra@2ndquadrant.com>, "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2020-06-25T15:46:54Z
Lists: pgsql-hackers, pgsql-docs
On Wed, Jun 24, 2020 at 7:38 PM Bruce Momjian <bruce@momjian.us> wrote: > I think my main point is that work_mem was not being honored for > hash-agg before, but now that PG 13 can do it, we are again allowing > work_mem not to apply in certain cases. I am wondering if our hard > limit for work_mem is the issue, and we should make that more flexible > for all uses. I mean, that's pretty much what we're talking about here, isn't it? It seems like in your previous two replies you were opposed to separating the plan-type limit from the execution-time limit, but that idea is precisely a way of being more flexible (and extending it to other plan nodes is a way of making it more flexible for more use cases). As I think you know, if you have a system where the workload varies a lot, you may sometimes be using 0 copies of work_mem and at other times 1000 or more copies, so the value has to be chosen conservatively as a percentage of system memory, else you start swapping or the OOM killer gets involved. On the other hand, some plan nodes get a lot less efficient when the amount of memory available falls below some threshold, so you can't just set this to a tiny value and forget about it. Because the first problem is so bad, most people set the value relatively conservatively and just live with the performance consequences. But this also means that they have memory left over most of the time, so the idea of letting a node burst above its work_mem allocation when something unexpected happens isn't crazy: as long as only a few nodes do that here and there, rather than, say, all the nodes doing it all at the same time, it's actually fine. If we had a smarter system that could dole out more work_mem to nodes that would really benefit from it and less to nodes where it isn't likely to make much difference, that would be similar in spirit but even better. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
Commits
-
Add hash_mem_multiplier GUC.
- d6c08e29e7bc 14.0 landed
- 78530c8e7a5a 13.0 landed
-
HashAgg: use better cardinality estimate for recursive spilling.
- 3a232a3183d5 13.0 landed
- 9878b643f37b 14.0 landed
-
Remove hashagg_avoid_disk_plan GUC.
- bcbf9446a298 14.0 landed
- 5a6cc6ffa914 13.0 landed
-
Doc fixup for hashagg_avoid_disk_plan GUC.
- d33f33539d7f 13.0 landed
- 7ce461560159 14.0 landed
-
Rework HashAgg GUCs.
- 13e0fa7ae50c 13.0 landed
- 92c58fd94801 14.0 landed
-
Disk-based Hash Aggregation.
- 1f39bce02154 13.0 cited
-
Implement partition-wise grouping/aggregation.
- e2f1eb0ee30d 11.0 cited
-
Defer creation of partially-grouped relation until it's needed.
- 4f15e5d09de2 11.0 cited