Re: Bg_writer and checkpointer

Поиск
Список
Период
Сортировка
От Jeff Janes
Тема Re: Bg_writer and checkpointer
Дата
Msg-id CAMkU=1zF9wjRWyxd4dUo5CoG=nX8xs=xgNXigHW_P5fecSteXQ@mail.gmail.com
обсуждение исходный текст
Ответ на Bg_writer and checkpointer  (Rajesh Kumar <rajeshkumar.dba09@gmail.com>)
Ответы Re: Bg_writer and checkpointer  (Rajesh Kumar <rajeshkumar.dba09@gmail.com>)
Список pgsql-admin
On Fri, Apr 19, 2024 at 11:16 AM Rajesh Kumar <rajeshkumar.dba09@gmail.com> wrote:
I have read multiple online blogs, watched videos and still not clarified about 1. Actual difference between bg_writer and checkpointer. When I am querying update set, If bgwriter flushes dirty buffer to base every 200ms(bgwriter_delay), why would I need checkpointer to invoke bgwriter? 

Sometimes the documentation is better than blogs and videos.  The bgwriter doesn't write every dirty buffer, only enough that backends needing to evict pages will generally find that the one selected to evict is already clean.  The checkpointer needs to write out every dirty buffer no already written out by someone else, as well as fsync them all (regardless of who wrote them out)
 
1. How the flow works?

Dml-->wal_buffer-->also copied to shared_buffer--> commit-->flushed to pg_wal using wal writer -->checkpointer-->fsync to datapath-->bgwriter flushed to base.

Generally the committing process flushes the pg_wal itself.  The wal writer is only important for synchronous_commit=off processes, or for large transactions where the  wal needs to be written several times over the course of one transaction.

Also, the changes are written to shared_buffers before wal_buffer, but since they are protected by the same lock I think the ordering is mostly just an implementation detail.

Cheers,

Jeff

В списке pgsql-admin по дате отправления:

Предыдущее
От: Jeff Janes
Дата:
Сообщение: Re: Intermittent Query Performance Issue
Следующее
От: Rajesh Kumar
Дата:
Сообщение: Re: Bg_writer and checkpointer