PostgreSQL tuning

Discussing PostgreSQL tuning is beyond the scope of this book. You may want to checkout out PostgreSQL 10 Admin Cookbook or PostgreSQL 10.0 High Performance, both from Packt Publishing, for in-depth coverage of these topics.

The default configuration of PostgreSQL is generally very conservative and is meant to prevent the database server from hogging all the system resources. On production servers, you can safely increase some parameters in the postgresql.conf file to get better performance. Here are some settings for PostgreSQL 9.6 that you can use to get started:

max_connections = 80 
shared_buffers = 256MB 
effective_cache_size = 768MB 
work_mem = 3276kB 
maintenance_work_mem = 64MB 
min_wal_size = 2GB
max_wal_size = 4GB
checkpoint_completion_target = 0.9 wal_buffers = 7864kB default_statistics_target = 100

You will need to restart PostgreSQL after modifying these settings.

The pgtune utility can help in finding a more suitable configuration. An online version is available at http://pgtune.leopard.in.ua/:

Connect to the website and fill in the following form:

  • DB Version: Use the database version you have installed (by default, 9.6 in Debian Stretch or 10.5 in Ubuntu 18.04).
  • OS Type: Linux.
  • DB Type: Choose Online transaction processing system, as Odoo instances are heavy users of transactions.
  • Total Memory (RAM): Put the amount of RAM you want to allocate to PostgreSQL this will be almost all of it if you are using a dedicated server (see more details about the dedicated database server in the next paragraph).
  • Number of CPUs (core): The value of this parameter will be the amount of CPU/core you want to allocate to PostgreSQL.
  • Number of Connections: The max number of simultaneous queries your database server will accept.
  • Data Storage: The type of data storage device. For example, SSD or HDD.

If your instance is heavily loaded, you will benefit from separating the database server and the Odoo server onto two different hosts. Don't use two virtual machines running on the same physical server if you reach this point use two physical servers with a high-speed network connection between both. In that case, you will need to ensure that the pg_hba.conf file on the database server host allows password-authenticated connections on the database from the Odoo server, and that the postgresql.conf file lets the PostgreSQL server listen in on the network interface connecting both servers.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset