http://www.perlmonks.org?node_id=160200

Marcello has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I have an application which forks of child processes to do all the work. At the moment, every child process creates its own database connection, does its work and closes the database connection again. This causes a lot of connections to be made to the database.

What I would like to do is to create one database connection, and let all child processes use this same connection. But sometimes the database connection drops, and a new one needs to be created.

Question 1: Is it wise to use the same database handle for all child processes?
Question 2: How do I check if a database handle has been destroyed (e.g. connection lost) without performing a query? I want the server process only to create the database connection, and check if it is still usuable by child processes or otherwise restore it.