http://qs321.pair.com?node_id=160294


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"