PostgreSQL Checkpoints and Performance Tuning
Explanation
When running XWiki with PostgreSQL, you may notice log messages similar to the following in the PostgreSQL logs:
2013-04-03 18:44:36 EEST LOG: checkpoints are occurring too frequently (22 seconds apart)
2013-04-03 18:44:36 EEST HINT: Consider increasing the configuration parameter "checkpoint_segments".
2013-04-03 18:46:05 EEST LOG: checkpoints are occurring too frequently (6 seconds apart)
2013-04-03 18:46:05 EEST HINT: Consider increasing the configuration parameter "checkpoint_segments".This indicates that PostgreSQL is triggering checkpoints too often, which increases disk activity and slows the database down. XWiki reaches that point during the operations that generate many database writes at once, such as:
- Importing large wiki Pages,
- Installing extensions,
- Rolling back document versions,
- Rebuilding indexes,
- Bulk updates or migrations.
The parameter the hint names, checkpoint_segments, was removed in PostgreSQL 9.5 and replaced by max_wal_size, so on any supported version the setting to raise is that one. Both it and checkpoint_timeout live in postgresql.conf, and PostgreSQL applies them on a configuration reload:
max_wal_size = 2GB
checkpoint_timeout = 15minThose values are a starting point rather than a recommendation: the right ones depend on how much write traffic the wiki produces and on how much disk space the write-ahead log may occupy.