ERIC SHEFFERMAN <DOT> COM

Blog-o-Goodness

WordPress Fun – Displaying the Number of Database Queries

Today is just a quick little addition to the footer of the blog to show how many database queries it took to build the web page and how much time it took.

This code is taken from the WordPress Default theme in the footer file. It is commented out so that it doesn’t display, but the information is there is case you want it.

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

I’m changing the word order a little to:

Queries <?php echo get_num_queries(); ?>  | Seconds: <?php timer_stop(1); ?>

This code gets placed in the current theme’s footer file footer.php.

Right now on a random page of my blog it says:

Queries 33 | Seconds: 0.547

I’m running Wp-Super Cache so to get changes I’ve made to show up right away, I have to clear the cache first. After that each copy of the page should be served from the cache and be much quicker (although since they are cached with the data from the original page generation, they still show the same number of queries and seconds).

For now, this is just a playing around with WordPress thing — but eventually this will be more important as I start trying to reduce the number of queries required and get the pages to be generated faster.

Share

Category: Plugins, WordPress

Tagged: , , , ,

Leave a Reply

Resource

Thoughts

So much of life, it seems to me, is determined by pure randomness. - Sidney Poitier

Keep Up With
Eric Shefferman

Via RSS
    

Via Email Updates
Name:
Email:

Categories

Archives

The following link is not for people: I do not like it, Sam I Am.