Performance issues - mysql_connect

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Performance issues - mysql_connect

Post by spacebiscuit »

Hi,

My host has contacted me to say that my site is causing performance issues on the server

"There were win32 pipes left open in the application pool of the server this
site was hosted on and on checking a sufficient random selection, they were
all owned by this domain."

my site has its content supplied from a MYSQL database and lots of connections are made each time a page is requested. I use the following function to connect:

mysql_connect

..however I have just realised that I am not closing the connection, could this possible be the "win32 pipes" that the host is referring to?

Any feedback would be appreciated.

Thanks,

Rob.
User avatar
andym01480
Forum Contributor
Posts: 390
Joined: Wed Apr 19, 2006 5:01 pm

Re: Performance issues - mysql_connect

Post by andym01480 »

You only need to connect to the database once for a page.

I would connect once at the top of index.php and then that connection is open for all the times I query the database from includes in that instance of index.php. If every you time you query the database you connect - I guess that is the problem!
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Re: Performance issues - mysql_connect

Post by spacebiscuit »

Yes I am only connecting once on each page, but I think each time theuser clicks on a different page another link is opened.

Would it be better to use a global variable to make the link and that way connections would not have to be opened.

Or should I just close the connection once MYSQL has been executed?

Thanks,

Rob.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Performance issues - mysql_connect

Post by onion2k »

"win32 pipes left open in the application pool of the server" is a funny way of describing a database connection. Is that definitely what the hosting company means?
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Re: Performance issues - mysql_connect

Post by spacebiscuit »

I'm not 100% sure but it is what I am guessing/

Rob.
User avatar
andym01480
Forum Contributor
Posts: 390
Joined: Wed Apr 19, 2006 5:01 pm

Re: Performance issues - mysql_connect

Post by andym01480 »

Google the issue and you'll find naff hosting companies winging about this all over the web - the solution seem to be to change hosting companies to one that uses Linux!!!! 8O I'm not starting a Windows/Linux fight on a PHP forum BTW 8O

Probably not a database problem. http://www.simplemachines.org/community ... c=197185.0 is one example that everyone quotes on this issue!
Post Reply