I have tested the parallelism with simple query and I don't understand the results.
I checked the following parameters from pg_settings
:
max_parallel_workers = 8
max_parallel_workers_per_gather = 2
I run the following query (the table contains ~16M rows):
explain analyze
select *
from tbl
where value<>-1
results:
Gather (cost=1000.00 .. 1136714.86 rows=580941 width=78 actual time=0.495..3057.813 rows = 587886 loops=1)
workers planned: 2
workers launched: 2
-> parallel seq scan on tbl (cost=0.00..10776.76 rows=242059 width=718) (actual time=0.095..2968.77 rows=195962 loops=3)
filter: (value<>-1::integer)
rows removed by filter: 5389091
plain time: 0.175ms
exection time: 3086.243ms
max_parallel_workers
and max_parallel_workers_per_gather
?
when each of the values will be used ?max_parallel_workers
limits the number of parallel worker processes that can be active at the same time in the whole database cluster. It must be less or equal to max_worker_processes
.
max_parallel_workers_per_gather
limits the number of parallel worker processes that can be used for a single query.
The idea is to limit the resources for parallel query while making sure that no single query can hog all the resources.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With