DB Internals AtlasPostgreSQL 18.6 Home About

Parameter · Write-Ahead Log / Settings

synchronous_commit

Sets the current transaction's synchronization level.

  • Default: on
  • Type: enum
  • Values: local · remote_write · remote_apply · on · off
  • Applies: Session (any user)

In plain words

When you COMMIT, PostgreSQL normally waits until the WAL for that transaction is safely on disk before saying "done". synchronous_commit lets you choose how much to wait for. off answers immediately (a crash may lose the last fraction of a second of commits, but never corrupts data). With synchronous standbys configured, on, remote_write and remote_apply also wait for a standby.

It can be set per session or even per transaction, so important writes can wait and unimportant ones do not.

For DBAs and operators

ValueCOMMIT waits until
offnothing: WAL is flushed by the WAL writer within about 3 × wal_writer_delay
localWAL flushed on the primary
remote_writelocal flush + sync standby(s) wrote it to their OS
onlocal flush + sync standby(s) flushed it to disk
remote_applylocal flush + sync standby(s) replayed it (visible to queries)

The remote levels only matter when synchronous_standby_names is non-empty; otherwise on, remote_write and remote_apply behave like local.

off is not like fsync=off

With off the transaction is reported committed before its WAL is durable. A crash can lose those transactions, but the database stays consistent: no corruption, just a short window of lost commits. It's a common, safe trade-off for logging tables or sessions doing many tiny commits: SET LOCAL synchronous_commit = off;.

Waiting for standbys

  • Waiting backends show wait_event = 'SyncRep' in pg_stat_activity. If all sync standbys are gone, commits hang until one returns or the setting changes; the transaction is already locally committed, so canceling the wait gives WARNING: canceling wait for synchronous replication due to user request with "The transaction has already committed locally, but might not have been replicated to the standby."
  • remote_apply gives read-your-writes on the standby, but commit latency then includes replay (and any recovery_min_apply_delay!).

How to change it

Any user can change it for their session with SET.

See it in context

Synchronous replication Write-ahead log (WAL) WAL writer The big picture Life of a DELETE

Related parameters

synchronous_standby_names wal_writer_delay fsync commit_delay recovery_min_apply_delay

All Write-Ahead Log parameters