Re: Blocking excessively in FOR UPDATE

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Claudio Freire" <klaussfreire(at)gmail(dot)com>
Cc: "postgres performance list" <pgsql-performance(at)postgresql(dot)org>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Blocking excessively in FOR UPDATE
Date: 2011-11-04 17:07:49
Message-ID: 4EB3D5950200002500042A60@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Claudio Freire <klaussfreire(at)gmail(dot)com> wrote:
> On Fri, Nov 4, 2011 at 1:26 PM, Kevin Grittner
> <Kevin(dot)Grittner(at)wicourts(dot)gov> wrote:
>> As already pointed out, SELECT FOR UPDATE will require a disk
>> write of the tuple(s) read. If these are glutting, increasing
>> shared_buffers would tend to make things worse.
>
> I thought shared_buffers improved write caching.
> We do tend to write onto the same rows over and over.

PostgreSQL is very aggressive about holding on to dirty buffers as
long as possible, in hopes of reducing duplicate page writes. This
can work against the goal of consistent latency. In our shop we
needed to make the background writer more aggressive and keep shared
buffers in the 0.5GB to 2GB range (depending on hardware and
workload) to prevent write gluts leading to latency spikes. In the
mildly surprising department, the OS seemed to do a decent job of
spotting pages receiving repeated writes and hold back on an OS
level write, while pushing other pages out in a more timely fashion
-- there was no discernible increase in OS write activity from
making these changes. I know other people have had other
experiences, based on their workloads (and OS versions?).

Before anything else, you might want to make sure you've spread your
checkpoint activity as much as possible by setting
checkpoint_completion_target = 0.9.

-Kevin

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Claudio Freire 2011-11-04 17:22:42 Re: Blocking excessively in FOR UPDATE
Previous Message Claudio Freire 2011-11-04 16:48:51 Re: Blocking excessively in FOR UPDATE