fsync
Flush WAL and data changes to disk before a commit reports success.
- デフォルト
on- Range
- on, off
- Restart needed
- いいえ
- Default checked on
- PostgreSQL 18
何ができるか
The master switch for durability. With it off, the server hands writes to the OS and acknowledges commits without waiting for the disk; a crash can then lose or tear data. synchronous_commit = off buys much of the same speed without the corruption risk.
デフォルト値
on. on (PostgreSQL 18).
Check the current value
SHOW fsync; SELECT setting, unit, boot_val, context, source, pending_restart FROM pg_settings WHERE name = 'fsync';
Change it
ALTER SYSTEM SET fsync = off; SELECT pg_reload_conf();
No restart: reload with SELECT pg_reload_conf() or pg_ctl reload. It cannot be changed per session (context is sighup).
When to change it
Almost never in production. The legitimate cases are throwaway load tests and an initial bulk load into a cluster you will back up or rebuild before serving traffic.
What can go wrong
Off leaves acknowledged commits in the OS page cache, so a crash, power loss or disk error can corrupt the cluster beyond repair; docs advise considering full_page_writes = off alongside, which removes torn-page protection on top. Turning it back on does not undo damage taken while it was off.
Questions about fsync
What is the default value of fsync in PostgreSQL?
on. on (PostgreSQL 18).
Does changing fsync require a restart?
No. No restart: reload with SELECT pg_reload_conf() or pg_ctl reload. It cannot be changed per session (context is sighup).
When should I change fsync?
Almost never in production. The legitimate cases are throwaway load tests and an initial bulk load into a cluster you will back up or rebuild before serving traffic.
Back to all PostgreSQL settings, or check the PostgreSQL manual for every option.
Check fsync on your own server
SQLly runs the query above against PostgreSQL and the other engines in this reference, from one desktop app on macOS, Windows and Linux.
このページのテキストとデータ: CC BY 4.0、出典は SQLly (sqlly.app) と明記してください。 コードと SQL スニペット: MIT. ライセンスの詳細