PGTune suggests PostgreSQL settings for maximum performance on the given hardware. It isn't a silver bullet for PostgreSQL optimization: many settings depend not only on the hardware, but also on the size of the database, the number of clients and the complexity of queries. An optimal configuration can be made only when all of these are taken into account, so use the result as a good starting point.

Principles

  • Do no harm: PostgreSQL defaults are changed only where your hardware and workload justify it
  • Settings, which can prevent PostgreSQL from starting on some builds or systems, are explained in warnings
  • Settings, which take effect only after restart, are marked as "restart required"

Choosing DB Type

Choose the type closest to the main workload of the database. Database size is set separately in "Total Data Size"

Web application
many short, simple queries, mostly reads. Examples: websites, APIs, SaaS backends
Online transaction processing system
many concurrent short transactions with frequent writes. Examples: payments, orders, bookings, inventory
Data warehouse
few long analytical queries over large amounts of data, bulk data loads. Examples: reporting, analytics, business intelligence
Desktop application
PostgreSQL shares the computer with other programs and uses little memory. Examples: developer workstation, local or test database, desktop application
Mixed type of application
both short transactions and heavy analytical queries. Examples: application, which also runs reports on the same database

Before applying the configuration

  • Read the warnings above the configuration
  • Apply the configuration on a test or staging server first
  • Apply the same settings on replicas
  • Monitor the database after the change and adjust settings for your workload

Useful links