pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dmitry Koterov <dmitry@koterov.ru>
To: Postgres General <pgsql-general@postgresql.org>
Subject: Bgwriter and pg_stat_bgwriter.buffers_clean aspects
Date: Fri, 26 Dec 2008 00:43:44 +0300
Message-ID: <d7df81620812251343h12072e11id0fae9d4d4b54ff4@mail.gmail.com> (raw)
In-Reply-To: <d7df81620812251337s41fcbefdyf7089dd8c57e6214@mail.gmail.com>
References: <d7df81620812251337s41fcbefdyf7089dd8c57e6214@mail.gmail.com>

Hello.

I am trying to tune PostgreSQL write parameters to make writing operation
fast on a heavy-loaded database (a lot of inserts/updates).
After resetting the pg_stat_bgwriter statistics (I do it by deleting
global/pgstat.stat file and restarting PostgreSQL) I monitor the following:

# select * from pg_stat_bgwriter;
 checkpoints_timed | checkpoints_req | buffers_checkpoint | buffers_clean |
maxwritten_clean | buffers_backend | buffers_alloc
-------------------+-----------------+--------------------+---------------+------------------+-----------------+---------------
                 8 |               0 |              19092 |             0
|                0 |            2285 |         30148

So, you see that some time after resetting the statistics we have:
- a large value in buffers_backend;
- a zero buffers_clean.

Why?

Documentation:
http://www.westnet.com/~gsmith/content/postgresql/chkp-bgw-83.htm<http://www.westnet.com/%7Egsmit...;
says that "buffers_backend ... [is a number of]  times a database backend
(probably the client itself) had to write a page in order to make space for
the new allocation", and "buffers_clean ... [means that] the background
writer cleaned ... buffers (cleaned=wrote out dirty ones) during that time".

What I am trying to achieve is that all writing operation are performed
asynchronously and mostly flushed to the disk before a CHECKPOINT occurred,
so CHECKPOINT is cheap thanks to bgwiter work.

Could you please explain what happened and what large buffers_backend and
zero buffers_clean mean?


Related parameters:

shared_buffers = 512MB
fsync = on
synchronous_commit = off
wal_writer_delay = 2000ms
checkpoint_segments = 20
checkpoint_timeout = 1min
checkpoint_completion_target = 0.8
checkpoint_warning = 1min
bgwriter_delay = 10ms
bgwriter_lru_maxpages = 1000
bgwriter_lru_multiplier = 10

view thread (6+ messages)  latest in thread

Message-ID: <d7df81620812251343h12072e11id0fae9d4d4b54ff4@mail.gmail.com>
Permalink:  ../d7df81620812251343h12072e11id0fae9d4d4b54ff4@mail.gmail.com/
Also on:    postgresql.org/message-id/d7df81620812251343h12072e11id0fae9d4d4b54ff4@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: dmitry@koterov.ru, pgsql-general@postgresql.org
  Subject: Re: Bgwriter and pg_stat_bgwriter.buffers_clean aspects
  In-Reply-To: <d7df81620812251343h12072e11id0fae9d4d4b54ff4@mail.gmail.com>
  References: <d7df81620812251337s41fcbefdyf7089dd8c57e6214@mail.gmail.com> <d7df81620812251343h12072e11id0fae9d4d4b54ff4@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox