29
Mar
2009
Subscribe
Bookmark and Share

wordpressIf you are running a Wordpress blog, you might want to keep a keen eye on its plugins to know how many queries and the time required to process them they are producing on your web pages.  This is particular useful if you are trying to optimize your database in order to save the resources your server has assigned to your blog.  Here is a simple code to add to your blog’s pages.

Just add this code wherever you want within your blog’s theme (usually it is added to single.php and page.php files):

<?php echo $wpdb->num_queries; ?> <?php _e(‘queries’); ?>. <?php timer_stop(1); ?> <?php _e(’seconds’); ?>

If you want to know a little more about this code, I have dissected it below, describing what the single pieces do:

  1. <?php echo $wpdb->num_queries; ?> = display the number of queries the page has got.
  2. <?php timer_stop(1); ?> = returns the time to process the page.

Tags: trick, WebTalk, Wordpress



WP Greet Box icon
Hello there! If you are new here, you might want to subscribe to the RSS feed for updates on this topic.

Related Articles Latest Articles

If you can not find what you are looking for, you might want to try Google Advanced Search and get thousands of results, specifically selected for you.

Google Advanced Search
.

Leave a Comment

If you want to show an image next to your comments, get your gravatar now!

XHTML - You can use the following tags:  <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CommentLuv Enabled


Incoming Search Terms for the Article:

php show db queries blog -

All contents are licenced under a Creative Commons Licence.
Best screen resolution 1280x800 or higher.
Web Talk is best viewed in Firefox.