How to do it...

Find these settings in the postgresql.conf file for the desired PostgreSQL instance and perform the following steps:

  1. Set max_connections to three times the number of processor cores on the server. Include virtual (hyperthreading) cores. Set shared_buffers to 4GB for servers with up to 64 GB of RAM. Use 8GB for systems with more than 64 GB of RAM.
  2. Set work_mem to 8MB for servers with up to 32 GB of RAM, 16MB for servers with up to 64 GB of RAM, and 32MB for systems with more than 64 GB of RAM. If max_connections is greater than 400, divide this by two.
Systems with exceedingly large amounts of RAM (256GB and above) do not require artificially halving the final suggested value for work_mem.
  1. Set maintenance_work_mem to 1GB ...

Get PostgreSQL High Availability Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.