Re: DBI: For speed-critical forking server, is DB reconnection in each child required? And prepared statements?

Rob Fries <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.general
Message-ID <CANLJvaHcHVz=H0gh8sBo4B5xhe=wWfCihWVe_2w5KEQe0r+oKw@mail.gmail.com>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.