Database disconnection and switch inside a single bgworker - Mailing list pgsql-hackers

From Michael Paquier
Subject Database disconnection and switch inside a single bgworker
Date
Msg-id CAB7nPqRp=SbXZ8v6htCP-dnaF95=HwQ4uRnFJf4da6phrsdvCw@mail.gmail.com
Whole thread Raw
Responses Re: Database disconnection and switch inside a single bgworker  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hi all,

Currently, bgworkers offer the possibility to connect to a given
database using BackgroundWorkerInitializeConnection in bgworker.h, but
there is actually no way to disconnect from a given database inside
the same bgworker process.

One of the use cases for that would be the possibility to have the
same bgworker performing for example some analysis on a database A,
like some analysis of statistics using a common database like
postgres, and then perform some actions on another database like,
let's imagine an ANALYSE on a given relation only on database B.

Using the infrastructure of 9.4 as of now, it would be possible of
course to have a bgworker process launching some other child processes
dynamically on different databases, but users (including me) might not
want to do that all the time.

Database disconnection would be also pretty cool for things like
parallel query processing using a pool of bgworker processes that all
the backends could use in parallel as a single ressource.

Note that I didn't have a look at the code yet to see how it would be
possible to do that (looks tricky though), if any infrastructure is
needed or if it could be possible to do that without modifying the
core code of Postgres. So, opinions about that as well as additional
thoughts are welcome!

Regards,
-- 
Michael



pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: information schema parameter_default implementation
Next
From: Sawada Masahiko
Date:
Subject: Re: Logging WAL when updating hintbit