PostgreSQL

PostgreSQL WAL Configuration: fsync, synchronous_commit, and Checkpoint Tuning

Tune PostgreSQL WAL for durability and performance. Covers synchronous_commit tradeoffs, checkpoint frequency monitoring, WAL archiving, and full_page_writes safety.

JusDB Team
October 16, 2025
Updated June 20, 2026
5 min read

WAL (Write-Ahead Log) configuration affects PostgreSQL durability, performance, and replication. Getting it wrong means either data loss risk or unnecessary I/O overhead.

Key WAL Parameters

ini
# postgresql.conf
wal_level = replica          # minimal, replica, or logical
fsync = on                   # NEVER disable in production
synchronous_commit = on      # on, remote_write, remote_apply, local, off
wal_buffers = 64MB           # default -1 (auto ~3% of shared_buffers)
wal_writer_delay = 200ms     # how often wal writer flushes
checkpoint_timeout = 15min   # max time between checkpoints
max_wal_size = 2GB           # trigger checkpoint when WAL exceeds this
min_wal_size = 80MB

synchronous_commit Tradeoffs

text
Setting         Data Loss Risk    Write Latency
----------------|-----------------|-------------
on (default)    None              Higher
remote_apply    None (with HA)    Highest
local           On standby only  Medium
off             Up to 3×wal_writer_delay  Lowest
sql
-- Per-transaction override (e.g., for non-critical writes)
SET LOCAL synchronous_commit = off;
INSERT INTO audit_log (event) VALUES ('page_view');
COMMIT;

Monitor Checkpoint Frequency

sql
SELECT checkpoints_timed, checkpoints_req,
       checkpoint_write_time, checkpoint_sync_time,
       buffers_checkpoint, buffers_clean
FROM pg_stat_bgwriter;

-- checkpoints_req >> checkpoints_timed means max_wal_size is too small
-- Increase max_wal_size to reduce I/O spikes from forced checkpoints

WAL Archiving

ini
archive_mode = on
archive_command = 'wal-g wal-push %p'
archive_timeout = 300   # force archive at least every 5 minutes

full_page_writes

ini
full_page_writes = on  # NEVER disable — prevents partial page write corruption
# After a checkpoint, first write to any page includes full page image in WAL
# Required for crash safety

Key Takeaways

  • Never disable fsync or full_page_writes — these prevent data corruption
  • If checkpoints_req is high, increase max_wal_size to reduce I/O spikes
  • Use synchronous_commit = off per-transaction for non-critical writes to reduce latency
  • Set archive_timeout to limit RPO exposure when WAL archiving to S3

JusDB Can Help

WAL misconfiguration is a common cause of both performance problems and data loss. JusDB can review your WAL configuration and tune it for your durability requirements.

Share this article

JusDB Team

Official JusDB content team

Keep reading

PostgreSQL 19 Beta: Every New Feature That Matters to DBAs

PostgreSQL 19 Beta 1 (June 4, 2026) brings parallel autovacuum, the native REPACK command for online table rebuilds, 2x faster inserts under foreign-key load, online logical replication without a restart, WAIT FOR LSN for read-your-writes consistency, and default changes (JIT off, lz4 TOAST, RADIUS removed). A DBA-focused walkthrough of what changed and what to test before GA.

PostgreSQL14 minJun 15, 2026
Read

PostgreSQL Performance Tuning Playbook: A Top-Down Method for Faster Queries

A repeatable, top-down method for tuning PostgreSQL: measure with pg_stat_statements, read plans with EXPLAIN (ANALYZE, BUFFERS), fix queries and indexes before parameters, then tune memory, I/O, WAL, connection pooling, and autovacuum — with a ready-to-adapt postgresql.conf baseline.

PostgreSQL16 minMay 31, 2026
Read

PostgreSQL Architecture Deep Dive: Process Model, MVCC, WAL & Replication Explained

Walk through PostgreSQL's multi-process architecture, shared/local memory layout, page-organized storage, MVCC tuple versioning, the WAL write path, the query execution pipeline, and physical + logical replication — all with ASCII flow diagrams that show how data and control actually move through the system.

PostgreSQL18 minMay 31, 2026
Read