{"Entry":{"collection":"guc","key":"bgwriter_lru_maxpages","name":"bgwriter_lru_maxpages","aliases":[],"metadata":{"baseline":false,"boot_human":"Not specified","boot_val":null,"category":"Resource Usage / Background Writer","category_zh":"","changed_in":["10","18"],"changes":[{"documentation_changed":false,"fields":{},"from":"8.0","status":"added","to":"8.1"},{"documentation_changed":true,"fields":{},"from":"8.1","status":"changed","to":"8.2"},{"documentation_changed":true,"fields":{},"from":"8.2","status":"changed","to":"8.3"},{"documentation_changed":true,"fields":{},"from":"9.1","status":"changed","to":"9.2"},{"documentation_changed":false,"fields":{"max_val":{"from":"1000","to":"1073741823"}},"from":"9.6","status":"changed","to":"10"},{"documentation_changed":false,"fields":{"extra_desc":{"from":null,"to":"0 disables background writing."}},"from":"17","status":"changed","to":"18"}],"content_hash":"d81666d7f53f5d44fb595524827ee1b39239bbab81ed6b2d5583bb9233715a32","context":"","default_changed_in":[],"default_history":[{"from":"9.0","to":"19","value":"100"}],"editorial":{"advice":{"olap":"Bulk writes can reach bgwriter_lru_maxpages limits continuously. Measure total bytes written, checkpoints, and storage queueing, not just foreground query latency.","oltp":"Tune bgwriter_lru_maxpages only with bgwriter and checkpoint metrics. The goal is fewer backend writes and smoother latency without excessive repeated writes; change one dimension at a time.","small":"A small host usually needs conservative write smoothing. Aggressive bgwriter_lru_maxpages can consume I/O needed by foreground work, so retain the default unless backend writes are a measured problem."},"mechanism":["bgwriter_lru_maxpages caps how many LRU-selected dirty buffers the background writer writes in one round. Zero disables this background-writing activity but does not disable checkpoints.","The writer tries to create enough clean reusable buffers for predicted demand, but this cap bounds each round. If it is reached repeatedly, foreground backends may still have to write buffers themselves.","The prediction comes from recent allocations multiplied by bgwriter_lru_multiplier, and rounds are separated by bgwriter_delay. Raising the cap can smooth latency at the cost of extra write amplification. Its SIGHUP context allows configuration reload without a server restart."],"pitfalls":["Changing bgwriter_lru_maxpages without applying its documented unit and configuration context.","Optimizing an isolated benchmark while ignoring concurrent aggregate resource use.","Assuming a configured value guarantees operating-system or storage behavior.","Failing to retest startup, failover, and workload latency after the change."],"references":[{"title":"PostgreSQL 19 Beta 4: bgwriter_lru_maxpages","url":"https://www.postgresql.org/docs/19/runtime-config-resource.html#GUC-BGWRITER-LRU-MAXPAGES"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["bgwriter_lru_multiplier","bgwriter_delay","bgwriter_flush_after","shared_buffers","checkpoint_completion_target"],"summary":"bgwriter_lru_maxpages — Background writer maximum number of LRU pages to flush per round. Observed in PG9.0–19 Beta 4; its last measured boot default is 100 in PG19 Beta 4, with sighup context. This is a beta-snapshot fact and can change before PostgreSQL 19 GA."},"enumvals":[],"first_version":"8.1","group":"Resource Usage","group_slug":"resource","imported_at":"2026-09-27T17:57:30.887956+08:00","intro_commit":{},"key":"bgwriter_lru_maxpages","last_version":"20","max_val":"","min_val":"","name":"bgwriter_lru_maxpages","position":45,"present_in":["8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6","10","11","12","13","14","15","16","17","18","19","20"],"short_desc":"In each round, no more than this many buffers will be written by the background writer.","short_desc_zh":"","source_rev":"english-manuals:cecf294c06db6e3d428d15f0cbd2c451b2d084c43d6f8d7e3c695885883255e6","unit":"","vartype":"integer"}},"Definition":{"Collection":"guc","Key":"bgwriter_lru_maxpages","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"bgwriter_lru_maxpages","SourceRevision":"english-manuals:cecf294c06db6e3d428d15f0cbd2c451b2d084c43d6f8d7e3c695885883255e6","Facts":{"boot_val":"100","category":"Resource Usage / Background Writer","context":"sighup","description":"In each round, no more than this many buffers will be written by the background writer. Setting this to zero disables background writing. (Note that checkpoints, which are managed by a separate, dedicated auxiliary process, are unaffected.) The default value is 100 buffers. This parameter can only be set in the postgresql.conf file or on the server command line.","doc":{"anchor":"GUC-BGWRITER-LRU-MAXPAGES","file":"runtime-config-resource.html","lang":"en","sha256":"2e207c599f0884dfbe594558c478a2c7c132578981071e980e2015f31dfce28c","slug":"18"},"documented":true,"enumvals":null,"extra_desc":"0 disables background writing.","lang":"en","max_val":"1073741823","metadata_version":"18","min_val":"0","name":"bgwriter_lru_maxpages","short_desc":"Background writer maximum number of LRU pages to flush per round.","source":"pg-settings-source-snapshot","unit":null,"vartype":"integer"},"ManualEvidence":{"doc":{"anchor":"GUC-BGWRITER-LRU-MAXPAGES","file":"runtime-config-resource.html","lang":"en","sha256":"2e207c599f0884dfbe594558c478a2c7c132578981071e980e2015f31dfce28c","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"bgwriter_lru_maxpages","SourceDatabase":"center","Version":"18","Locale":"en","Title":"bgwriter_lru_maxpages","Summary":"In each round, no more than this many buffers will be written by the background writer. Setting this to zero disables background writing. (Note that checkpoints, which are managed by a separate, dedicated auxiliary process, are unaffected.) The default value is 100 buffers. This parameter can only be set in the postgresql.conf file or on the server command line.","BodyHTML":"\u003cp\u003eIn each round, no more than this many buffers will be written by the background writer. Setting this to zero disables background writing. (Note that checkpoints, which are managed by a separate, dedicated auxiliary process, are unaffected.) The default value is 100 buffers. This parameter can only be set in the postgresql.conf file or on the server command line.\u003c/p\u003e","SourceRevision":"english-manuals:cecf294c06db6e3d428d15f0cbd2c451b2d084c43d6f8d7e3c695885883255e6","ContentHash":"321b4755b878b0804966a40abbd1d35a6027f2384c12a86b34e42f122fe2a638","Payload":{"description":"In each round, no more than this many buffers will be written by the background writer. Setting this to zero disables background writing. (Note that checkpoints, which are managed by a separate, dedicated auxiliary process, are unaffected.) The default value is 100 buffers. This parameter can only be set in the postgresql.conf file or on the server command line."}},"RequestedLocale":"zh-Hans","Fallback":true,"Versions":["10","11","12","13","14","15","16","17","18","19","20","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6"],"Locales":["en"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
