Mysql_pconnect

software development

#1

Hi!

I want to reduce the number of mysql connections (my conuery ratio is 0.2) , but i can’t use mysql_pconnect since php runs as CGI, and I cannot change that in the control panel. Is there any workaround to create a connection and let cgi-php use that one instead of reconnecting every time a page is requested?


#2

I don’t think we have the access to MySQL cnf file. I guess we have to use other methods.

What I can think is to create a counter in the database. The counter increases by 1 if there is a people connected to database. It reduces by 1 if there is a people disconnected. If the counter reaches the max allowed connects, no more people can connect to database.

You need to be careful with the in and out connections. If the counter is not accurate, you will have less people allowed to connect to database.

Save $97 (MAX Discount) with code: [color=#CC0000]97YES[/color] Sign Up NOW or More Codes Here


#3

Not sure of the answer to your question, but if a lot of your connection needs are for simple select statements, you could cache the results and avoid the queries all together.


Read my blog. You know you want to…


#4

that’s a good idea! can you recommend me a good php mysql abstraction class, wich uses query caching that only connects if it fails to find a cached result?
currently i’m using codeigniter’s active record but i think it connects to the sql server if there is a cached result too.


#5

nevermind!

I made some modifications to the CodeIgniter frameworks Database class and now it only connects to the mysql server if it cannot find a suitable sql result cache file!

that means 0 connections if the cache is valid! cool!