Bgwriter and pg_stat_bgwriter.buffers_clean aspects

From: "Dmitry Koterov" <dmitry(at)koterov(dot)ru>
To: pgsql-performance(at)postgresql(dot)org
Subject: Bgwriter and pg_stat_bgwriter.buffers_clean aspects
Date: 2008-12-25 23:08:16
Message-ID: d7df81620812251508r3ba4a736g13a237778c238aa3@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-performance

Hello.

(Sorry, I have sent this letter to pgsql-general@ first and only then -
noticed that there is a special performance mailing list. So I post it here
now.)

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/%7Egsmith/content/postgresql/chkp-bgw-83.htm>
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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gerhard Wiesinger 2008-12-26 08:25:16 Re: Conditional commit inside functions
Previous Message Dmitry Koterov 2008-12-25 21:43:44 Bgwriter and pg_stat_bgwriter.buffers_clean aspects

Browse pgsql-performance by date

  From Date Subject
Next Message Nikolas Everett 2008-12-26 14:34:09 Re: Slow table update
Previous Message Dmitry Koterov 2008-12-25 21:43:44 Bgwriter and pg_stat_bgwriter.buffers_clean aspects