Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

client_backend vs parallel_worker?

Tags:

postgresql

I'm running:

select *
from pg_stat_activity

And it shows 2 rows with same query content (under query field), and in active state,

but one row show client_backed (backend_type) and the other row show parallel_worker (backend_type)

  1. why do I have 2 instances of same query ? (I have run just one query in my app)
  2. what is the different between client_backed and parallel_worker ?
like image 655
Boom Avatar asked Jun 25 '26 07:06

Boom


1 Answers

Since PostgreSQL v10 there is parallel processing for queries:

If the optimizer decides it is a good idea and there are enough resources, PostgreSQL will start parallel worker processes that execute the query together with your client backend. Eventually, the client backend will gather all the information from the parallel workers and finish query processing.

This speeds up query processing, but uses more resources on the database server. The parameters that govern this are, among others max_parallel_workers, which limits the total limit for parallel worker processes, and max_parallel_workers_per_gather, which limits the numbers of parallel workers for a single query.

like image 119
Laurenz Albe Avatar answered Jun 28 '26 02:06

Laurenz Albe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!