Re: pg 9.1 brings host machine down

From: Craig Ringer <ringerc(at)ringerc(dot)id(dot)au>
To: Konstantin Mikhailov <ekimka(at)gmail(dot)com>
Cc: Patric Bechtel <patric(dot)bechtel(at)gmail(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: pg 9.1 brings host machine down
Date: 2012-06-10 03:26:41
Message-ID: 4FD413F1.5080404@ringerc.id.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On 06/09/2012 01:52 AM, Konstantin Mikhailov wrote:
> Thanks alot. I've tried to play with work_mem and after few days
> of the production testing pg behaves much better. See no more
> files in the pgsql_tmp folder. pg processes consumes reasonable
> memory, no swap operation any more. I've studied official pg
> docs about work_mem an still have no idea which optimal value
> work_mem should have. 1MB is obviously too small. I've increased
> up to 32m. due to a lot of the sorts and hash joins in the queries.
>
The trouble is that the optimal work_mem depends on your workload and
hardware. Or that's my understanding, anyway.

A workload with a few simple queries that sort lots of big data might
want work_mem to be really huge (but not so huge that it causes
thrashing or pushes indexes out of cache).

A workload with lots of really complicated queries full of CTEs,
subqueries, etc might use several times work_mem per connection, and if
there are lots of connections at once might use unexpectedly large
amounts of RAM and cause thrashing or cache competition even with quite
a small work_mem.

Right now, Pg doesn't have the diagnostic tools or automatic tuning to
make it possible to determine an ideal value in any simple way, so it's
mostly a matter of examining query plans, tuning, and monitoring.
Automatic tuning of work_mem would be great, but would also probably be
_really_ hard, and still wouldn't solve the problem where n sorts can
consume n times work_mem, so you can't give complicated_query a strict
enough work_mem limit without severely starving big_simple_query or
having to run a session-local "SET work_mem" before it.

A system for auto-tuning Pg at runtime would be amazing, but also very
_very_ hard, so tweaking params based on benchmarking and examination of
runtime performance is your only real option for now.

--
Craig Ringer

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Mark Thornton 2012-06-10 08:20:26 Performance of CLUSTER
Previous Message Kevin Kempter 2012-06-09 17:58:44 partitioning performance question