pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Teja Jakkidi <teja.jakkidi05@gmail.com>
Cc: pgsql-admin <pgsql-admin@lists.postgresql.org>
Subject: Re: Workers in Postgres
Date: Mon, 25 Jul 2022 22:44:48 -0400
Message-ID: <2122536.1658803488@sss.pgh.pa.us> (raw)
In-Reply-To: <BBAD8621-02B5-4978-BC53-EC8759A7B55B@gmail.com>
References: <BBAD8621-02B5-4978-BC53-EC8759A7B55B@gmail.com>

Teja Jakkidi <teja.jakkidi05@gmail.com> writes:
> 1. What is a worker process exactly in Postgres? 

It's a background process that can be started if the planner decides
that a particular query would benefit from parallelization.  If so,
the original session process (the "leader") cooperates with one or
more temporarily-spawned workers to perform the query.

> 2. is max_parallel_workers specific to a session or instance. My max_parallel_workers is set to 8. If it is specific to instance, does it mean at any point of time I can only see 8 parallel processes despite the number of transactions in the db? 

Per instance.  There is a different knob max_parallel_workers_per_gather
that gives you some control over how many workers a given leader will
try to use.

Before you say "oh, I've got max_connections set to 100, so I'd better
raise max_parallel_workers to a few hundred" ... don't do that unless
you've got a few hundred CPUs in the machine.  While session processes
might be sitting around doing nothing much except waiting for the next
query, workers generally are busy throughout their lifespan.  So it's
counterproductive for max_parallel_workers to be more than roughly the
number of available CPUs --- setting it higher just encourages the
system to create parallel workers that it can't use effectively.

> 3. Does number of worker process have anything to do with active connections to the database.

See above.

			regards, tom lane





view thread (3+ messages)

Message-ID: <2122536.1658803488@sss.pgh.pa.us>
Permalink:  ../2122536.1658803488@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2122536.1658803488@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: tgl@sss.pgh.pa.us, teja.jakkidi05@gmail.com, pgsql-admin@lists.postgresql.org
  Subject: Re: Workers in Postgres
  In-Reply-To: <2122536.1658803488@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox