Chris Farrell Membership
TomTom
Terapeak
This site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies. Find out more.

Reduce WordPress CPU Usage – Step #2 Display Page Load Time + Number of Queries

 Posted by  Add comments
 

Reduce WordPress CPU Usage – Step #2 Display Page Load Time + Number of Queries

This article is part of the, ‘Reduce WordPress CPU Usage’ series.

A high CPU usage can be caused by the number of calls that WordPress has to make to the database. WordPress retrieves almost all of the data it needs for pages, posts and plugins from the database. Installing a caching mechanism such as the WP-SuperCache plugin will help but the calls will still be needed to produce the cached files.

Display Page Loading Time + Number of Queries

To check how long it takes your pages to load and how many SQL queries were executed insert this snippet of code in your footer.php file to display the page load time and number of queries executed. You can used the code almost anywhere but the footer.php file is probably the best place.

  • Simply paste the following code on your footer.php file:
  • More information on the function get_num_queries can be found at the WordPress Codex [http://codex.WordPress.org/Function_Reference/get_num_queries].
<?php echo get_num_queries(); ?> queries in <?php timer_stop(1); ?>  seconds.

Essentially, we’re calling on the server to tell us how many times it was accessed to create the page. To see the result of this code go to your blog, scroll down and there at the bottom of the page you will see a line something like:

65 queries in 0.518 seconds.

If you don’t want the information public just enclose the code in a html comment block, i.e.:

<!-- <?php echo get_num_queries(); ?> queries in <?php timer_stop(1); ?>  seconds. -->

In this case you will have to view the page source to see the information. just look for the comment line in the footer.

If you have any tips you can give on this subject just add your comments below…


KingSolutions.org.uk is hosted on JustHost

  3 Responses to “Reduce WordPress CPU Usage – Step #2 Display Page Load Time + Number of Queries”

  1. Just what I was looking for. In your opinion, how good is WordPress 3 when it comes to CPU usage?

    • Sorry maxload but I’ve only used WordPress so have no experience of other CMP. Maybe someone else could give you the answer?

      The 5 great content management systems I know of are:
      WordPress [http://www.wordpress.org/],
      Joomla [http://www.joomla.org/],
      Drupal [http://drupal.org/],
      ExpressionEngine[http://expressionengine.com/] and
      Cushy [http://www.cushycms.com/]

  2. Nice tips. These things really do make a big difference to the load time of pages.

 Leave a Reply

(required)

(required)

88 queries in 0.881 seconds (Child).