Postgresql 10 - Parallel configuration

HudsonPH picture HudsonPH · Oct 30, 2018 · Viewed 9.8k times · Source

There are 4 configurations to enable the parallel and do the optimization, but the documentation of PostgreSQL doesn't says anything about values or calculation. My questions are:

1- How to calculate the values of max_parallel_workers, max_parallel_workers_per_gather and max_worker_processes?

2- The work_mem can be calculate on base of connections and memory(RAM), but the work_mem needs to change something if I enable the parallel?

My supposition is: if the machine has 8 cores the max_parallel_workers is 8 and the values of worker process and per gather are 32(8*4), the number 4 I took from the original configuration that is 4 gathers per 1 parallel work.

Answer

HudsonPH picture HudsonPH · Nov 12, 2018

After some searching I found some answers, this can help who wants to enable and to have a base configuration, case you have 4 cores(CPU):

your max worker processes will be the amount of cores and the max parallel needs to have the same amount:

max_worker_processes = 4
max_parallel_workers = 4

the gather is more complex because this value can be manipulated base on your needs and resource it is necessary to test to get a best value, but to startup values you can use cores/2.

max_parallel_workers_per_gather = 2

This is not a final answer, there some missing points... I am still searching and updating this answer or waiting for a better one.