PostgreSQL Background writer
In the last post we discussed about checkpoint process, in this tutorial we will discuss about “postgres: Background writer”
Background writer writes dirty buffers into the datafiles.
PostgreSQL: Background writer :
postgres: Background writer is started by the postmaster process during the start of instance.
According to the documentation, There is a separate server process called the background writer, whose function is to issue writes of “dirty” (new or modified) shared buffers. It writes shared buffers so server processes handling user queries seldom or never need to wait for a write to occur.
In other words, background writer also writes the dirty buffers to disk which helps checkpointer process to do less IO when CHECKPOINT occurs.(we know checkpointer process sometimes writes dirty buffers to data files.)
The main objective of background writer process is to make sure that free buffers are available for use.
The algorithm that background writer process uses when writing dirty buffers is as follows.
postgres: writer process parameters
bgwriter_delay [200ms by default , 10ms – 10s possible] – This parameter specifies how long the process should wait between successive executions.
bgwriter_lru_maxpages [100 pages by default, 0 – 1000 possible] – The bgwriter_lru_maxpages parameter specifies the maximum number of buffers that will be written by the process in each iteration.
bgwriter_lru_multiplier [2.0 by default, 0-10.0 possible] – multiplier ratio determining how many pages should be cleaned for every incoming dirty page, based on counts from last delay periods. For example, if the value is set to 2, and if incoming buffers pages are 10, dirty buffers will be cleared until there are 20 buffers available or until bgwriter_lru_maxpages has been written.
In the next post we will discuss about autovacuum launcher process.
Thank you for giving your valuable time to read the above information. I hope the content served your purpose in reaching out the blog.
Suggestions for improvement of the blog are highly appreciable. Please contact us for any information/suggestion/feedback.
If you want to be updated with all our articles
please follow us on Facebook | Twitter
Please subscribe to our newsletter.