Mysql_connect vs mysql_pconnect

Alright, I spent the last hour on Google and all I got was confused, so I’m turning here for help :slight_smile:

I keep hearing conflicting opinions about when/if to use mysql_pconnect and mysql_connect. On the one hand, I hear mysql_pconnect is more efficient, on the other hand, I have been told that it is a bad idea to use it on a shared server (which I am on here), and may not save connections at all. The only thing I am certain of is that it doesn’t work when PHP runs as CGI, but apart from that, I feel pretty much clueless… how should I decide which one to use?

Can anyone enlighten me? :slight_smile: Thanks!


In my experience, using pconnect doesn’t hurt, but it doesn’t necessarily help.

Years ago users would complain about pconnect not working, and in tests I found that in fact it did not work. At all. Every time you called it, it made a new connection.

However, I think the PHP people may have fixed that bug (it was quite a while ago). It’s definitely advantageous to use them on our system since we charge for excessive MySQL usage (and connections are particlularly computationally expensive).

They may not save any connections, but they won’t hurt.