How do I display database query statistics on Wordpress site? How do I display database query statistics on Wordpress site? wordpress wordpress

How do I display database query statistics on Wordpress site?


Try adding this to the bottom of the footer in your template:

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


To explain pix0r's code:


wordpress has a easy solution now

There is a function called get_num_queries() and as specified in other answers timer_stop().

<?php echo get_num_queries(); _e(' queries'); ?> in <?php timer_stop(1); _e(' seconds'); ?></p>

get_num_queries() - returns the number of database queries during the WordPress execution and accepts no parameters