Re: shouldn't mysql_pconnect force reuse of mysql connections?

From: Date: Tue, 19 Aug 2003 17:07:08 +0000
Subject: Re: shouldn't mysql_pconnect force reuse of mysql connections?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-160023@lists.php.net to get a copy of this message
* Thus wrote anders thoresson (listor@thoresson.net): > > function db_connect ($user, $pwd, $db, $debug = 0) > { > $link = @mysql_pconnect("localhost", "$user", "$pwd"); > if($link && mysql_select_db("$db")) > ... > > I thought that making another or a third call to db_connect would reuse > the same connection to the database, since I use mysql_pconnect() to > connect. But listing the active processes indicates something else: > > > | Id | User | Host | db | Command | Time | State | Info > | 64494 | thore | localhost | thore | Sleep | 222 | | > | > | 64497 | thore | localhost | thore | Sleep | 218 | | > | > ... This is expected, this is the behavour of mysql. when php requests a pconnection, mysql will allocate a certain amount of pooled connections that will be used. To really test this to see if php is reusing the connection, kill all processes in mysql. Then (making sure that no other script somewhere else connects to database) run your script once. Your resulting process list will have only one item listed the second time you request in php you'll have two, and so on. Until the number of connections in the pool gets filled up will mysql tell php to use an id that exists. there is a setting in mysql to change this, but i can't recall off hand the name of the setting. Curt -- "I used to think I was indecisive, but now I'm not so sure."

« previous php.general (#160023) next »