Re: Allow sorts to use more available memory

From: Shaun Thomas <sthomas(at)peak6(dot)com>
To: Andy Colson <andy(at)squeakycode(dot)net>
Cc: Robert Schnabel <schnabelr(at)missouri(dot)edu>, pgsql-performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Allow sorts to use more available memory
Date: 2011-09-12 17:57:58
Message-ID: 4E6E4826.8050002@peak6.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On 09/12/2011 12:47 PM, Andy Colson wrote:

> work_mem is not the total a query can use. I believe each step can
> use that much, and each backend can use it for multiple bits. So if
> you had two backends, each doing 2 sorts, you'd use 2*2 = 4 * 2GB =
> 8GB.

Exactly. Find a big query somewhere in your system. Use EXPLAIN to
examine it. Chances are, that one query has one or more sorts. Each one
of those gets its own work_mem. Each sort. The query have four sorts? It
may use 4*work_mem. On a whim a while back, I doubled our 8MB setting to
16MB on a test system. During a load test, the machine ran out of
memory, swapped out, and finally crashed after the OOM killer went nuts.

Set this value *at your own risk* and only after *significant* testing.
Having it too high can have rather unexpected consequences. Setting it
to 1 or 2GB, unless you have VERY few threads, or a TON of memory, is a
very, very bad idea.

--
Shaun Thomas
OptionsHouse | 141 W. Jackson Blvd. | Suite 800 | Chicago IL, 60604
312-676-8870
sthomas(at)peak6(dot)com

______________________________________________

See http://www.peak6.com/email-disclaimer/ for terms and conditions related to this email

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Andy Colson 2011-09-12 18:02:44 Re: Allow sorts to use more available memory
Previous Message Andy Colson 2011-09-12 17:47:54 Re: Allow sorts to use more available memory