Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: dbh->disconnect or leave to scope

by andreas1234567 (Vicar)
on Jan 19, 2011 at 05:45 UTC ( #883062=note: print w/ replies, xml ) Need Help??

in reply to dbh->disconnect or leave to scope

It depends largely on your choice of database and your use of it.

  • Are your database server's connect operations lightweight (MySQL) or heavyweight (DB2) ?
  • Do you connect and disconnect often?
  • Do you maintain a small or large number of simultaneous connections?
  • Do you fork ?
No matter how great and destructive your problems may seem now, remember, you've probably only seen the tip of them. [1]

Comment on Re: dbh->disconnect or leave to scope
Select or Download Code
Re^2: dbh->disconnect or leave to scope
by Cagao (Monk) on Jan 19, 2011 at 10:16 UTC

    We connect to 3 DB platforms (all on MySQL tho).

    One is a single master, the other 2 are masters with several slaves.

    I don't pass dbh's around between methods, since sometimes I may have connected to a slave for read-only operations, but might have passed the the dbh into a method requiring write access to the master, so it's easier to connect in each method (to the relevant master/slave), plus, it's MySQL, so not a massive hit on the connection time.

    We clearly connect/disconnect a fair amount, but this isn't causing performance implications (yet).

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (7)
As of 2015-03-28 22:16 GMT
Find Nodes?
    Voting Booth?

    When putting a smiley right before a closing parenthesis, do you:

    Results (627 votes), past polls