How many mysql queries

Hey all,

I wanna improve my site performance and I’d like to know how many mysql queries when I generate a php page. Can anyone please help to how to this? Thanks in advance!

Number of queries doesn’t matter. Quality of queries and database setup does.
There can be one of 30 queries, that slows whole site down.
Or even not SQL query at all.
Improving site performance in subject of profiling, not blind repairing of something-that-might-be-slow-but-I-don’t-know-yet.

as few as possible

As for counting number of queries, actually executed on the particular page, there is no way, unless you have your own function that runs a query.
Anyway, as I said above, not number of queries, but profiling - finding most time consuming part of your scripts - must be your concern

Thanks for your replies. Yes, I was actually wondering if there’s a way to count how many queries on each page. Is there a php function for it? Unfortunately I have no programming basics, I don’t have the knowledge to take the smartest way like profiling you mentioned above. I just thought maybe I can learn something and finally figure out.

Yes it does. And big time. Less queries per page you have the better.

Is there a php function for it?

No.

I just thought maybe I can learn something and finally figure out.

I hope you understand now that number of queries won’t help you.

First thing you have to understand is not whole visible page being generated by PHP script. There are many other resources, that load separately: images, javascripts, style sheets.
As I can see on your site, page itself loads relatively fast. But it’s style sheet take a lot more time.
So, first of all you have to determine slow part. It can be not SQL at all.

Edit:
Yes. It is CSS, not SQL that slows your site down.
http://www.bikegamer.com/templates/a.../css/style.css
loads terrible slow. Dunno why. Bad server probably.
Actually it serves each request too slow. Even pictures.

It’s easy, just set up a count in the $_GLOBAL array and increase it by 1 each time you use a query (with the line to add to the count right after the line running the query. At the end of the page echo the number of queries run and reset the count.

i don’t do php, but i’m curious… why would you need to reset the count at the end of the page?