Skip to main content

Automatic configuration of PostgreSQL parameters (Auto-tuning)

Auto-tuning automatically configures PostgreSQL internal parameters based on the allocated resources: RAM, vCPU (virtual CPU), storage type and enabled extensions. No manual intervention is required.

info

This configuration is applied when a cluster is created and automatically recalculated when resources are modified.

Adjusted parameters

Memory

ParameterFormula / ValueContext
shared_buffers25 % of RAM, capped at 8 GBpostmaster (restart required)
effective_cache_size75 % of RAMuser (immediate)
work_mem(RAM − shared_buffers) / ((max_connections + max_worker_processes) × 6), minimum 4 MBuser (immediate)
maintenance_work_memRAM / 16, minimum 64 MB, maximum 8 GBsighup (reload)
autovacuum_work_mem2 GB if maintenance_work_mem ≥ 2 GB, otherwise unsetsighup (reload)

Parallel queries (vCPU ≥ 4)

These parameters are set only if the cluster has at least 4 vCPU. Smaller instances use the PostgreSQL default values.

ParameterFormula / ValueContext
max_worker_processesvcpuCountpostmaster (restart required)
max_parallel_workersvcpuCountpostmaster (restart required)
max_parallel_workers_per_gathervcpuCount / 2⌉, capped at 4user (immediate)
max_parallel_maintenance_workersvcpuCount / 2⌉, capped at 4user (immediate)

Autovacuum

vCPUautovacuum_max_workers
< 16Unset (default value: 3)
16 - 314
≥ 325

Storage

Storage typerandom_page_costeffective_io_concurrency
Standard (HDD)4.02
GP2 / IO1 (SSD)1.1256

WAL (Write-Ahead Logging)

WAL file sizes:

  • min_wal_size: 1 GB.
  • max_wal_size: 4 GB.

Fixed parameters

These parameters remain constant regardless of the cluster sizing:

  • wal_compression: lz4;
  • jit: off;
  • huge_pages: off.

PostgreSQL parameters

The following parameters are managed by the internal operator and cannot be configured:

  • Replication: primary_conninfo, synchronous_standby_names;
  • Backup: recovery_target_*, restore_command;
  • Archiving: archive_command, archive_mode;
  • WAL: wal_level, max_wal_senders;
  • Network: port, listen_addresses, hot_standby.

Special cases

TimescaleDB

If the TimescaleDB extension is enabled, the worker process parameters are adjusted accordingly:

ParametervCPU 4-15vCPU ≥ 16
max_worker_processes3 + vcpuCount + 83 + vcpuCount + 16
timescaledb.max_background_workers816

PostgreSQL 18+

For PostgreSQL versions 18 and above (≥ 4 vCPU), the internal I/O parameters are also adjusted:

  • io_workers: min(32, max(3, vcpuCount / 4)).

Configuration examples

Small cluster (1 GiB, 1 vCPU, Standard storage, PostgreSQL 17)

ParameterValue
shared_buffers256 MB
effective_cache_size768 MB
work_mem4 MB (floor value)
maintenance_work_mem64 MB (floor value)
random_page_cost4.0
effective_io_concurrency2

Intermediate cluster (8 GiB, 4 vCPU, GP2 storage, PostgreSQL 17)

ParameterValue
shared_buffers2 GB
effective_cache_size6 GB
work_mem4 MB
maintenance_work_mem512 MB
random_page_cost1.1
effective_io_concurrency256
max_worker_processes4
max_parallel_workers4
max_parallel_workers_per_gather2

Large cluster with TimescaleDB (32 GiB, 16 vCPU, IO1 storage, PostgreSQL 18, TimescaleDB)

ParameterValue
shared_buffers8 GB (cap)
effective_cache_size24 GB
maintenance_work_mem2 GB
autovacuum_work_mem2 GB
max_worker_processes35 (TimescaleDB formula)
max_parallel_workers16
max_parallel_workers_per_gather4 (cap)
autovacuum_max_workers4
timescaledb.max_background_workers16
io_workers4

Resource modification

When the resources of a cluster are modified through the API, the parameters are automatically recalculated and applied:

Change typeAffected parametersOperation required
RAM, vCPUshared_buffers, max_worker_processes, etc.Rolling restart
Storage typerandom_page_cost, effective_io_concurrencyConfiguration reload
Volume sizeNoneNone

Rolling restart

A rolling restart is triggered automatically when postmaster context parameters are modified. Each instance of the cluster is restarted one after another, which guarantees service continuity if you have at least one replica.

warning

When resources are decreased (RAM or vCPU), the parameters are adjusted downward accordingly. Ensure that your workload remains compatible with the new configuration.

For more details on the impact of the rolling restart, see the documentation on modifying the resources of a cluster.