Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Sharing database handle

by mamboking (Monk)
on Apr 18, 2002 at 18:16 UTC ( #160294=note: print w/replies, xml ) Need Help??

in reply to Sharing database handle

Instead of sharing a connection you probably want to do connection pooling. You could have your app open up a bunch of connections at application startup then as a child process is spawned it gets a connection from the pool. When it is finished it returns the connection to the pool. If there aren't any available connections then your process can block until one becomes available. Since opening and closing database connections is very costly this should greatly help your performance. Also, by pre-allocating the connections, you always have control over how many connections are out there.

Replies are listed 'Best First'.
Re: Re: Sharing database handle
by perrin (Chancellor) on Apr 18, 2002 at 18:40 UTC
    I don't think that will actually work. The trouble is, you can't easilly pass DBI objects (which involve open sockets and XS code) back and forth between processes.
Re: Re: Sharing database handle
by belg4mit (Prior) on Apr 24, 2002 at 02:24 UTC
    Here is a connection pooler, sqlrelay. Good thing is it has interfaces for numerous languages as well (so you can pool what would otherwise be per-language puddles). I haven't gotten around to setting it up yet (tuit deficit), but look forward to doing so.

    perl -pew "s/\b;([mnst])/'$1/g"

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://160294]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (1)
As of 2022-11-27 02:55 GMT
Find Nodes?
    Voting Booth?