pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
how does PostgreSQL determine how many parallel processes to start
4+ messages / 2 participants
[nested] [flat]

* how does PostgreSQL determine how many parallel processes to start
@ 2021-02-19 09:38  Luca Ferrari <fluca1978@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Luca Ferrari @ 2021-02-19 09:38 UTC (permalink / raw)
  To: pgsql-general <pgsql-general@lists.postgresql.org>

Hi all,
I know that parallel processes can be limited by
max_parallel_workers_per_gather and max_parallel_workers, as well as
the condition to consider a parallel plan is min_table_scan_size (and
index). But I would like to understand, once a table has been
considered for a parallel plan, and there is room for other workers,
how will PostgreSQL decide to start another process?

Thanks,
Luca





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: how does PostgreSQL determine how many parallel processes to start
@ 2021-02-19 09:43  Laurenz Albe <laurenz.albe@cybertec.at>
  parent: Luca Ferrari <fluca1978@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Laurenz Albe @ 2021-02-19 09:43 UTC (permalink / raw)
  To: Luca Ferrari <fluca1978@gmail.com>; pgsql-general <pgsql-general@lists.postgresql.org>

On Fri, 2021-02-19 at 10:38 +0100, Luca Ferrari wrote:
> I know that parallel processes can be limited by
> max_parallel_workers_per_gather and max_parallel_workers, as well as
> the condition to consider a parallel plan is min_table_scan_size (and
> index). But I would like to understand, once a table has been
> considered for a parallel plan, and there is room for other workers,
> how will PostgreSQL decide to start another process?

During planning, it will generate parallel and non-parallel plans
and take the one it estimates to be cheapest.

At execution time, PostgreSQL will use as many of the planned workers
as are currently available (max_parallel_workers).

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com






^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: how does PostgreSQL determine how many parallel processes to start
@ 2021-02-19 10:21  Luca Ferrari <fluca1978@gmail.com>
  parent: Laurenz Albe <laurenz.albe@cybertec.at>
  0 siblings, 1 reply; 4+ messages in thread

From: Luca Ferrari @ 2021-02-19 10:21 UTC (permalink / raw)
  To: Laurenz Albe <laurenz.albe@cybertec.at>; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>

On Fri, Feb 19, 2021 at 10:43 AM Laurenz Albe <laurenz.albe@cybertec.at> wrote:
> At execution time, PostgreSQL will use as many of the planned workers
> as are currently available (max_parallel_workers).

Thanks, but just to make it clear, assuming I execute almost
simultanously two identical queries that can be therefore be
parallelized, does that mean that the first one will be executed with
the max available parallele capacity and the second will "starve" on
parllelism being executed sequentially. Is this correct?
As a consequence to that, this also could mean that a query over a
small table could take more advanatge (in parallel sense) than a scan
on a larger table that was issued just a moment after (assuming both
table can be scanned in parallel), right?

Luca





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: how does PostgreSQL determine how many parallel processes to start
@ 2021-02-19 13:31  Laurenz Albe <laurenz.albe@cybertec.at>
  parent: Luca Ferrari <fluca1978@gmail.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Laurenz Albe @ 2021-02-19 13:31 UTC (permalink / raw)
  To: Luca Ferrari <fluca1978@gmail.com>; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>

On Fri, 2021-02-19 at 11:21 +0100, Luca Ferrari wrote:
> > At execution time, PostgreSQL will use as many of the planned workers
> > as are currently available (max_parallel_workers).
> 
> Thanks, but just to make it clear, assuming I execute almost
> simultanously two identical queries that can be therefore be
> parallelized, does that mean that the first one will be executed with
> the max available parallele capacity and the second will "starve" on
> parllelism being executed sequentially. Is this correct?
> As a consequence to that, this also could mean that a query over a
> small table could take more advanatge (in parallel sense) than a scan
> on a larger table that was issued just a moment after (assuming both
> table can be scanned in parallel), right?

Precisely.  That is why you have "max_parallel_workers_per_gather"
to limit the number of parallel workers available to a single query.

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com






^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2021-02-19 13:31 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-02-19 09:38 how does PostgreSQL determine how many parallel processes to start Luca Ferrari <fluca1978@gmail.com>
2021-02-19 09:43 ` Laurenz Albe <laurenz.albe@cybertec.at>
2021-02-19 10:21   ` Luca Ferrari <fluca1978@gmail.com>
2021-02-19 13:31     ` Laurenz Albe <laurenz.albe@cybertec.at>

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