Re: [HACKERS] Increasing parallel workers at runtime - Mailing list pgsql-hackers

From Robert Haas
Subject Re: [HACKERS] Increasing parallel workers at runtime
Date
Msg-id CA+TgmoaBOaFJCbQWHEeU2aXb=PJK02u+EETByPY8m49hGvKHzw@mail.gmail.com
Whole thread Raw
In response to [HACKERS] Increasing parallel workers at runtime  (Haribabu Kommi <kommi.haribabu@gmail.com>)
Responses Re: [HACKERS] Increasing parallel workers at runtime
Re: [HACKERS] Increasing parallel workers at runtime
List pgsql-hackers
On Mon, May 15, 2017 at 10:06 AM, Haribabu Kommi
<kommi.haribabu@gmail.com> wrote:
> This still needs some adjustments to fix for the cases where
> the main backend also does the scan instead of waiting for
> the workers to finish the job. As increasing the workers logic
> shouldn't add an overhead in this case.

I think it would be pretty crazy to try relaunching workers after
every tuple, as this patch does.  The overhead of that will be very
high for queries where the number of tuples passing through the Gather
is large, whereas when the number of tuples passing through Gather is
small, or where tuples are sent all at once at the end of procesisng,
it will not actually be very effective at getting hold of more
workers.  A different idea is to have an area in shared memory where
queries can advertise that they didn't get all of the workers they
wanted, plus a background process that periodically tries to launch
workers to help those queries as parallel workers become available.
It can recheck for available workers after some interval, say 10s.
There are some problems there -- the process won't have bgw_notify_pid
pointing at the parallel leader -- but I think it might be best to try
to solve those problems instead of making it the leader's job to try
to grab more workers as we go along.  For one thing, the background
process idea can attempt to achieve fairness.  Suppose there are two
processes that didn't get all of their workers; one got 3 of 4, the
other 1 of 4.  When a worker becomes available, we'd presumably like
to give it to the process that got 1 of 4, rather than having the
leaders race to see who grabs the new worker first.  Similarly if
there are four workers available and two queries that each got 1 of 5
workers they wanted, we'd like to split the workers two and two,
rather than having one leader grab all four of them.  Or at least, I
think that's what we want.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [HACKERS] Create publication syntax is not coming properly in pg_dump / pg_dumpall
Next
From: Peter Eisentraut
Date:
Subject: Re: [HACKERS] postgres 9.6.2 update breakage