Re: Treating work_mem as a shared resource (Was: Parallel Hash take II)

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Vladimir Rusinov <vrusinov(at)google(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Serge Rielau <serge(at)rielau(dot)com>, David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>, Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com>, Prabhat Sahu <prabhat(dot)sahu(at)enterprisedb(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Rafia Sabih <rafia(dot)sabih(at)enterprisedb(dot)com>, Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>, Haribabu Kommi <kommi(dot)haribabu(at)gmail(dot)com>, Oleg Golovanov <rentech(at)mail(dot)ru>
Subject: Re: Treating work_mem as a shared resource (Was: Parallel Hash take II)
Date: 2017-11-17 19:36:06
Message-ID: CAH2-WzmHSSaYgJSkJ2jip9RyyfivNudYRteWOJh_edBw3PN+pQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Nov 17, 2017 at 8:09 AM, Vladimir Rusinov <vrusinov(at)google(dot)com> wrote:
> FWIW, lack of per-connection and/or global memory limit for work_mem is major PITA when running shared and/or large-scale setup.
>
> Currently we are doing a poor job with the work_mem parameter because we don't have a good way to let our customers increase it without also giving them ability to shoot themselves in a foot.
> Even a simple param limiting global total number of work_mem buffers would help here.

I suspect that we can do better here just by allocating memory more
sensibly in a very simple way (something like my hash_mem proposal).
The relationship between aggregate memory usage and aggregate
throughput is very non-linear. One can imagine giving more memory to
hash joins, making each hash join much faster, having the overall
effect of *reducing* aggregate memory usage. The DBA can be more
generous with memory while actually decreasing aggregate memory usage.
This is at least possible with work_mem consuming operations that
involve hashing, like hash join and hash aggregate.

Simple benchmarking tools like pgbench enforce the idea that meeting
throughput requirements is the most important thing, but in reality
workloads are usually very bursty. It is often more important to be
able to stay on a smaller instance size while maintaining less than
excellent (but still acceptable) performance. Again, it's about the
economics.

--
Peter Geoghegan

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2017-11-17 19:49:23 Re: [COMMITTERS] pgsql: Add hash partitioning.
Previous Message Peter Eisentraut 2017-11-17 19:31:06 Re: [JDBC] [HACKERS] Channel binding support for SCRAM-SHA-256