On Thu, Jun 25, 2020 at 1:15 PM Jeff Davis <pg...@j-davis.com> wrote: > Unexpected things (meaning underestimates) are not independent. All the > queries are based on the same stats, so if you have a lot of similar > queries, they will all get the same underestimate at once, and all be > surprised when they need to spill at once, and then all decide they are > entitled to ignore work_mem at once.
Yeah, that's a risk. But what is proposed is a configuration setting, so people can adjust it depending on what they think is likely to happen in their environment. > That sounds more useful and probably not too hard to implement in a > crude form. Just have a shared counter in memory representing GB. If a > node is about to spill, it could try to decrement the counter by N, and > if it succeeds, it gets to exceed work_mem by N more GB. That's a neat idea, although GB seems too coarse. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company