Support » Plugins » 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… 😉

Viewing 2 replies - 1 through 2 (of 2 total)
  • I know this was posted 9 months ago, but it definitely applies to me. My site — — is using up boatloads of server CPU…they actually shut it down for a bit while we sorted things out. It’s been getting 3000+ visits/day since I redesigned it and started to use WP for content mgmt. I know there HAS to be quite a few ways to optimize this. Anyone care to help?
    Dave, you can see your plugin in use 🙂

    $wpdb has had query saving in it for a while now, and the latest from the CVS can also time queries. There are lots of things you can do to improve performance, including showing less items on the page, making sure you aren’t using any heavy plugins, try out the staticize caching plugin, etc. You might want to also consider a more powerful host, 3000+ visits a day should not be a problem.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Anyone need more info on query-counts?’ is closed to new replies.