Dirty block write paths

Once a block has been made dirty in shared memory, there are three possible ways it can be written back to the database, each tracked by a counter in pg_stat_bgwriter:

  • buffers_checkpoint: Clearing all of the dirty blocks included as part of a checkpoint write is accounted for here. This value jumps all at once when the checkpoint finishes, which makes monitoring this an alternative way to figure out when checkpoints are finished in addition to the log files.
  • buffers_backend: A backend (any process besides the background writer that also handles checkpoints) tried to allocate a buffer, and the one it was given to use was dirty. In that case, the backend must write the dirty block out itself before it can use the buffer ...

Get PostgreSQL 10 High Performance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.