1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PostgreSQLの裏側を学びたい(Step6:バックグラウンドライターを学ぶ)

1
Posted at

はじめに

前回までの続きです。今回はバックグラウンドライターについて学んでいきます。
今回も座学なので、ChatGPTに教えてもらいます。

writerとは何か

writer(バックグラウンドライター) は、PostgreSQLのバックグラウンドプロセスの1つで、
メモリ上にある「Dirty Page(更新済みページ)」を少しずつディスクに書き出す役割を持ちます。

目的はただ一つ:

I/Oのスパイク(負荷の集中)を防ぐこと。

もしcheckpointerだけで全ページをまとめて書いていたら、
数分ごとに大量のI/Oが発生してしまいます。
それを防ぐために、writerがこまめに「少しずつ書き戻す」しくみになっています。

🧠 checkpointerとの違い

プロセス タイミング 対象 目的
writer 頻繁(数百ms〜数秒ごと) 一部のDirty Page I/Oを平準化(負荷分散)
checkpointer 定期的(数分ごと) 全体のDirty Page データの永続化(安全ライン確定)

んんん???全然よくわからない💦💦💦💦片方でよくない??と感じてしまう。

checkpointerの処理を楽にするために、writerを使うらしいです。
writerは書き込み予約をするまでで実際には書き込まないで、checkpointerは実際にディスクの書き込みを実施していく。なるほどなぁ。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?