note 85670 added to function.mysql-pconnect
| From: | david at hundsness dot com | Date: | Thu, 11 Sep 2008 17:44:22 +0000 |
| Subject: | note 85670 added to function.mysql-pconnect | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-144339@lists.php.net to get a copy of this message | ||
Here's a recap of important reasons NOT to use persistent connections:
* When you lock a table, normally it is unlocked when the connection closes, but since persistent
connections do not close, any tables you accidentally leave locked will remain locked, and the only
way to unlock them is to wait for the connection to timeout or kill the process. The same locking
problem occurs with transactions. (See comments below on 23-Apr-2002 & 12-Jul-2003)
* Normally temporary tables are dropped when the connection closes, but since persistent connections
do not close, temporary tables aren't so temporary. If you do not explicitly drop temporary
tables when you are done, that table will already exist for a new client reusing the same
connection. The same problem occurs with setting session variables. (See comments below on
19-Nov-2004 & 07-Aug-2006)
* If PHP and MySQL are on the same server or local network, the connection time may be negligible,
in which case there is no advantage to persistent connections.
* Apache does not work well with persistent connections. When it receives a request from a new
client, instead of using one of the available children which already has a persistent connection
open, it tends to spawn a new child, which must then open a new database connection. This causes
excess processes which are just sleeping, wasting resources, and causing errors when you reach your
maximum connections, plus it defeats any benefit of persistent connections. (See comments below on
03-Feb-2004, and the footnote at http://devzone.zend.com/node/view/id/686#fn1)
----
Server IP: 208.69.120.35
Probable Submitter: 69.181.142.101
----
Manual Page -- http://www.php.net/manual/en/function.mysql-pconnect.php
Edit -- https://master.php.net/note/edit/85670
Del: integrated -- https://master.php.net/note/delete/85670/integrated
Del: useless -- https://master.php.net/note/delete/85670/useless
Del: bad code -- https://master.php.net/note/delete/85670/bad+code
Del: spam -- https://master.php.net/note/delete/85670/spam
Del: non-english -- https://master.php.net/note/delete/85670/non-english
Del: in docs -- https://master.php.net/note/delete/85670/in+docs
Del: other reasons-- https://master.php.net/note/delete/85670
Reject -- https://master.php.net/note/reject/85670
Search -- https://master.php.net/manage/user-notes.php