a few questions concerning mysql_pconnect

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
davidklonski
Forum Contributor
Posts: 128
Joined: Mon Mar 22, 2004 4:55 pm

a few questions concerning mysql_pconnect

Post by davidklonski »

Hello

I have been reading about mysql_pconnect (persistent connections) and I am a bit confused from the problems they seem to cause people.

Here is what I understand:
If I use mysql_pconnect instead of mysql_connect, then used connections from the same host, username & password will not be thrown away after the child process of the web server (I am using Apache) is done with them. They will persist for a whlie before being garbaged.
This allows the child process to continue using the same connection if another request is made to the same host, username & password and the connection was still alive.

I understand that many people are complaining that the number of persistent connections keep getting larger and larger.
This is because the Web server spawns many child processes and each has its own connection.

Here is my question:
I all of the connections will be made to the same, username & password, can that problem still occur?

I also understand that MySQL can limit the number of open connections. Is there a way to tell it not to limit it and what the cosequences of that would be?

thanks in advance
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

As far as I know, mysql_pconnect() is only good to use if you recieve a very high amount of hits (and with that, database accesses) to the site, and if the "wait_timeout" value is tweaked.

As i never myself use anything else than mysql_connect() I cannot comment wisely, but this; http://jeremy.zawodny.com/blog/archives/000173.html might be abit interesting to erad (?).
Post Reply