I just wanted to get an idea of where I stand when it comes to using queries. I would like to know if the amount of queries I'm using per page is considered waaaaaay too many.
I normally hit about 10 queries per page. They are mostly small select queries and don't grab a TON of info... just a small amount.
Is this considered bad? or about average?
PS. I would also like to add that I have quite a few visitors.. so these pages are called about 60 -70 times per minute.
10 queries is fairly typical. Some of my pages require quite a lot more.
If you're seeing several hundred, it could be problematic.
Mark
You're saying it will be a problem if I see serveral hundred per min? or per page?
I was looking at my MySQL runtime info and here is what it says.
This MySQL server has been running for 1 days, 17 hours, 10 minutes and 37 seconds Query statistics: Since its startup, 864,741
Per Hour: 21,000.61 Per Min: 350.01 Per Sec: 5.83
If your noticing some lag not caused by network latency then it's possible you have too many queries or just doing too much work I'd suggest a cache engine to alleviate some of the stress if possible
thanks MarkR & hutchic
To: Hutchic
Where can I get more info on Cache Engine's ... I would like to know more about that.. I've never heard of it.
The smarty template engine has cacheing built in PEAR has a cache module a quick search of google should return a number of resources I'm personally a fan of this one http://www.phpit.net/article/build-caching-system-php/
It's quite nice re:simplicity in that you can drop the header file into all your (viewable php) pages and they're cache enabled with no mucking about
Just make sure that you're not using one query to get data to run the next one. It's generally better to join them together into one query. I.e. something like this:
select userid from user_table where username='Sxooter'; (get userid) select address from detail_table where userid=123;
Instead, it's better to do something like:
select address from detail_table where user_table.userid=detail_table.userid and user_table.username='Sxooter';