Parameter · Resource Usage / I/O
backend_flush_after
Number of pages after which previously performed writes are flushed to disk. 0 disables forced writeback.
- Default:
0 - Type: integer (8kB)
- Range: 0 … 2MB
- Applies: Session (any user)
In plain words
Same idea as bgwriter_flush_after, but for writes that regular sessions do themselves (when they have to evict a dirty page). Off by default.
For DBAs and operators
Uses sync_file_range() on Linux; range 0–2 MB. Backends write data themselves when the bgwriter has not kept up, and during bulk writes using ring buffers (COPY, CREATE TABLE AS). Enabling it (e.g. 256 kB–2 MB) can smooth checkpoint fsync stalls on write-heavy systems, but adds writes for workloads that re-dirty pages that would otherwise be absorbed by the OS cache. Measure p99 latency before and after; pg_stat_io.writebacks by backend type shows the effect. Any user can SET it per session, so you can enable it just for a bulk-loading job.
How to change it
Any user can change it for their session with SET.
See it in context
Related parameters
bgwriter_flush_after checkpoint_flush_after wal_writer_flush_after