DjangoCon Europe 2023 | Tuning PostgreSQL to work even better

Tune your PostgreSQL performance like a pro by learning which parameters to adjust and how to optimize your setup for better query times and overall system efficiency.

Key takeaways
  • Postgres is designed to work well out of the box, but fine-tuning can still have a big impact.
  • Parameters can be categorized into connections and sessions, memory use, logging, and shared buffers.
  • Only a handful of parameters need to be changed to achieve good performance.
  • Shared buffers should be set to around 25-40% of available RAM.
  • Work mem should be set to around 50-70% of total memory available.
  • Maintenance work mem is important for tasks like vacuum and create index.
  • wal_buffers should be set to a reasonable value based on available disk space.
  • checkpoint_timeout should be set to a reasonable value based on system usage.
  • autovacuum should be enabled by default, but can be customized for specific use cases.
  • fsync and random_page_cost are important parameters to consider, but can be tricky to set.
  • tuning parameters can make a big difference in performance, but it’s important to test and monitor results.
  • most people don’t need to know about most parameters, and can just focus on a few key ones.
  • knowing how to tune parameters can help developers understand and work with Postgres better.
  • fine-tuning can take some experimentation, but is worth it for optimal performance.
  • it’s OK to just leave Postgres to do its thing, but knowing what parameters can be changed can help customize performance.