Re: mysql_pconnect / persistent database conections

From: Date: Fri, 28 Jan 2005 09:56:10 +0000
Subject: Re: mysql_pconnect / persistent database conections
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-207567@lists.php.net to get a copy of this message
Ben Edwards wrote:
Been meaning to investigate persistent database connections for a while. Coming from a rdbms background (oracle with a bit of whatcom sqlanywhare) I have always felt that the overhead of opening a connection at the beginning of each page was a little resource intensive. MySQL is not remotely the same beast as oracle - take pure session create times. I have a machine that runs both. Creating an oracle session with sqlplus command line takes in the region of 2 seconds (get around this for web apps by connection pooling). Creating a mysql connection (c client) takes in the region of 5 mS.
You also need to consider the memory / processor implications of caching connections (or keeping persistent connections) from your web server.
Anyway, I found mysql_pconnect and this sounds like just the ticket. Seems that I can just change my connect method from mysql_connect to mysql_pconnect and it will just work. I do have a couple of questions. Firstly what is the story with mysql_close. There is no mysql_pclose. I guess you don't need to close the connection at the end of each page but what if you do. Is mysql_close ignored if the connection was made with mysql_pconnect or douse it close the connection and next time mysql_pconnect is run it reconnects causing no benefit over mysql_pconnect. also what is the timeout likely to be? My other question is what happens if lots of people connect using the same user/password. I tend to do my own user management so everybody douse. Is doing my own user management really dodge, if we were talking about oracle I would probably say it is. Ben


« previous php.general (#207567) next »