21
Number of worker
processes
Zero (no parallel plan generated)
If the sample size is less than 512kB, the min_parallel_index_scan_size is set
to 512kB.
Fixed
If the 'parallel_workers' storage parameter is set for the table
Calculated using the formula
1 + log₃(sample size / min_parallel_index_scan_size)⌊ ⌋
But not exceeding max_parallel_workers_per_gather
The number of worker processes is determined similarly to sequential
scanning. The data volume expected to be read from the index (determined
by the number of index pages) is compared to the value of the
min_parallel_index_scan_siz parameter (default 512kB).
In the case of a sequential table scan, the data volume is determined by the
size of the entire table. However, with index access, the planner needs to
estimate how many index pages will be read. The details of how this works
are covered in the "Basic Statistics" section.
If the sample size is too small, the optimizer won't consider a parallel plan.
For example, accessing a single value will never be parallelized — there's
nothing to parallelize in this scenario.
If the sample size is large enough, the number of worker processes is
calculated using a formula, unless it's explicitly set in the table's
parallel_workers parameter (not the index).
The number of processes will not exceed the
max_parallel_workers_per_gather parameter's value.