Re: work_mem and shared_buffers - Mailing list pgsql-performance

From Scott Marlowe
Subject Re: work_mem and shared_buffers
Date
Msg-id dcc563d10711091112r73ef016dp56d01bd6dd04a1d3@mail.gmail.com
Whole thread Raw
In response to Re: work_mem and shared_buffers  ("Campbell, Lance" <lance@uiuc.edu>)
Responses Re: work_mem and shared_buffers  ("Campbell, Lance" <lance@uiuc.edu>)
Re: work_mem and shared_buffers  (Simon Riggs <simon@2ndquadrant.com>)
List pgsql-performance
On Nov 9, 2007 12:08 PM, Campbell, Lance <lance@uiuc.edu> wrote:
> How do you know when you should up the value of work_mem?  Just play
> with the number.  Is there a query I could do that would tell me if
> PostgreSql is performing SQL that could use more memory for sorting?

Trial and error.  Note that you can set work_mem for a given session.
While it may seem that making work_mem bigger will always help, that's
not necessarily the case.

Using this query:

select count(*) from (select * from myreporttable where lasttime >
now() - interval '1 week' order by random() ) as l

I did the following: (I ran the query by itself once to fill the
buffers / cache of the machine with the data)

work_mem Time:
1000kB 29215.563 ms
4000kB 20612.489 ms
8000kB 18408.087 ms
16000kB 16893.964 ms
32000kB 17681.221 ms
64000kB 22439.988 ms
125MB 23398.891 ms
250MB 25461.797 ms

Note that my best time was at around 16 Meg work_mem.  This data set
is MUCH bigger than 16 Meg, it's around 300-400 Meg.  But work_mem
optimized out at 16 Meg.  Btw, I tried it going as high as 768 Meg,
and it was still slower than 16M.

This machine has 2 Gigs ram and is optimized for IO not CPU performance.

pgsql-performance by date:

Previous
From: Vivek Khera
Date:
Subject: Re: dell versus hp
Next
From: "Campbell, Lance"
Date:
Subject: Re: work_mem and shared_buffers