Posted on December 23rd, 2008 in WP Tips-Tricks
| 9,065 views
If you want to display how many SQL queries have been made to your database as I’ve done on this blog like this:
50 queries in 0.437 seconds
Just open the footer.php in your theme folder and paste the following code at anywhere you like:
1 | <?php echo get_num_queries(); ?> queries in <?php timer_stop(1); ?> seconds |
Another code for displaying that but except regular visitors and search engine bots, we will use a conditional function to do that:
1 2 3 | <?php if (is_user_logged_in()) { ?> <?php echo get_num_queries(); ?> queries in <?php timer_stop(1); ?> seconds. <?php } ?> |
The get_num_queries() function returns the number of executed query during your page loading.
Thanks to Jean-Baptiste Jung for this useful tip.












UNITED STATES and using
3 Responses to “Display the number of SQL queries on your blog”
Cho mình hỏi là có phải bạn đã chèn code php vào bài viết trên để làm ví dụ ko ? Sao mình thấy mỗi lần refresh lại là cái ví dụ nó thay đổi vậy ?
Cám ơn hieudt về thủ thuật này !
Bạn nói đúng đấy, mình dùng plugin để chèn code php vào bài viết.
Plugin đó tên là WordPress PHP Exec. Bạn có thể vào đây để download: http://priyadi.net/archives/2005/03/02/wordpress-php-exec-plugin/