29
Mar
2009

How to know and display how many database queries your blog’s pages have got

CMS, Web Talk, WebmasterComments Off on How to know and display how many database queries your blog’s pages have got





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.



Related Articles Latest Articles
.

Comments are closed.


Copyright © 2007-2017 | Sitemap | Privacy | Back To Top
Best screen resolution 1280x800 or higher.
Web Talk is best viewed in Firefox.

Stat