Hey James,
I was running into a similar situation but for a backend system that
ran multiple quick scripts to check state for automation. I was
working on building a daemon that would hold the connections, adding
as needed and destroying excess using some POE modules.
while working on it though, our DBAs upgraded us to Oracle 11 which
has a built in DB Pool (DRCP) which we are utilizing now. if you are
using an Oracle DB, look into it. here is the connection string I am
using:
$self->{dbh} = DBI->connect("dbi:Oracle:$config->{sid}",
$config->{user}, $config->{pass},
{ AutoCommit => 0, ora_drcp => 1,
ora_drcp_class => "feedAutomation" } );
-Rob
On Sun, May 13, 2012 at 2:29 PM, James Marshall <[email protected]> wrote:
> I'm writing a forking HTTP server that needs to access a database with each
> hit. Speed is pretty important, so I was hoping to reuse database handles
> and prepared statement handles in the forked child processes. Is this
> possible, or do I really need to reconnect to the database and prepare the
> statements in each child?
>
> Info I found from googling, faqs, and list archives generally implies
> reconnection is required, but is inconclusive (at least what I found).
>
> Alternately, is there any way to clone (deep or shallow) a prepared
> statement handle without repreparing, or a database handle without
> reconnecting?
>
> The only solution I've come up with is to have the server daemon manage a
> pool of connected database handles and prepared statement handles, which
> complicates the program a bit. Any other solutions I'm missing?
>
> Thanks! Links to old discussions welcome if this has been answered before.
>
> James