Mysql_pconnect vs mysql_connect and Dreamhost?

software development



I’m trying to conserve my resources and make my database driven websites as efficient as possible so I don’t bog down the server.

I noticed Dreamhost talks about “Conueries” as 1 connection attempt is equal to 25 queries because of huge number of resources it takes to connect. So I started using mysql_pconnect for persistent connections instead of mysql_connect.

I did not know the difference between the two when I copied and pasted this from a tutorial when I first started learning MySQL.

As I understand it, there is a maximum number of persistent connections allowed, so when the maximum connections are used up if a bunch of people are viewing my site at one time, no one else can view my site? (most of the site depends on the database) If so, what is the maximum persistent connections allowed on Dreamhost?

What is a good strategy or code examples of better connection management if I have to use mysql_connect and make a new connection every time a page loads?


  1. Don’t worry too much about conueries. We don’t use them as a hard limit on MySQL usage anymore, as a lot of the MySQL problems we deal with nowadays involve sites which use slow queries, not sites which use too many queries.

  2. MySQL connections are only used while your site is generating pages (e.g, in the process of loading), not for the whole time a visitor’s looking at your site. I’m not certain what the connection limit is offhand, but it’s high enough that I really don’t hear about people running into it — other stuff breaks first.


Thanks for the response andrewf. So you would probably recommend using mysql_connect rather than mysql_pconnect as pconnect is a persistent connection that lasts throughout the whole time a visitor is looking at the site?

Also, what is an example of slow queries? I’m assuming these are inefficient queries that do a ton of work and cause a page to load slowly in the end?

Thanks a lot
Kind regards