Waynn Lue wrote:
Our site has been slowing down dramatically in the last few days, so
I've been trying to figure out why.  I ran some profiling scripts on
our site and saw that we're spending between 3-9 seconds on
mysql_connect.  Then I connected to our db and saw that there were
over 100 connections at the time, most of them sleeping.  Is this
because we don't close mysql connections until the end of script
execution?

Are you using mysql_pconnect or just mysql_connect? Persistent connections do what you outline and keep the connection sitting there. For this (and some other reasons) most people don't use persistent connections.

PHP should clean up regular _connect resources when the script(s) are finished running, you don't need to do it explicitly.

How do people generally structure their code to minimize the time they
keep mysql connections open?  Currently all db connections go through
one file, which gets included at the top of the file.  One other
question, is it better to open one connection, then re-use it later,
or just continually open and close per db call?

It'll be even slower to open/close per db call.

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to