Optimizing Standby Database Performance in PostgreSQL: Key Parameter Tuning Checklist

Optimizing Standby Database Performance in PostgreSQL: Key Parameter Tuning Checklist

To tune PostgreSQL parameters on a standby database with 16 CPUs and 16GB RAM for performance, consider the following settings:

  1. hot_standby: Set to on to enable queries during recovery.
  2. max_standby_archive_delay and max_standby_streaming_delay: Adjust these for conflict resolution in replication. Start with the default and adjust based on experience.
  3. wal_receiver_status_interval: Set to a lower value like 10 seconds for more frequent feedback to the primary.
  4. wal_receiver_timeout: Adjust as needed, starting from the default.
  5. shared_buffers: Set to about 4GB (25% of total RAM).
  6. effective_cache_size: Set to around 12GB (75% of total RAM).
  7. work_mem: Start with 256MB and adjust based on the query load.
  8. maintenance_work_mem: Set higher than work_mem, like 1GB, for maintenance tasks.
  9. max_parallel_workers: Set to the number of CPUs, i.e., 16.
  10. max_parallel_workers_per_gather: Begin with half of max_parallel_workers, i.e., 8.