Anyone need more info on query-counts?
I just went and hacked wp-db.php so that it would keep track of all queries for a session (instead of just the last one… or two), with some quick formatting for output. Then, when running on my internal server and a flag is set, I echo it all out.
I originally added this in as I wanted to know what exactly my 60-something queries were going towards… and I found a savings of about 10 queries by adding caching of the comments-count (which I think should be calculated and stored in the post itself to eliminate an extra query per post).
It also shows me that there is further optimization, if queries are a bigger hit (for my ISP, the SQL server is run off a different box, I think…), possibly by doing larger singular queries and then sorting/parsing out the bigger block of results in php. Things like querying all the categories once, or all the user info once (for sites with few posting users, of course!), and pulling from those cached results, could potentially alleviate even more…
Of course, it depends on the content on the page. If you have a ton of posts, sticking the comment-count in the post table would help a lot. If you have a bunch of active users, caching the user info would help. Another thing I’m looking at is the potential of putting the category back in the post for single category items — though, I broke out my ‘post type’ field for just that reason originally.
Anyway, if people are interested, I could pull together the very minor edits needed for those more-technically-oriented people who want to dig into what queries are happening… 😉
- The topic ‘Anyone need more info on query-counts?’ is closed to new replies.