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.

Sign up for News and Updates!
digg delicious stumbleupon technorati Google live facebook Sphinn Mixx newsvine reddit yahoomyweb

3 Responses to “Display the number of SQL queries on your blog”

  1. 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 ? :mrgreen:

  2. Cám ơn hieudt về thủ thuật này !

  3. nmask:

    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 ? :mrgreen:

    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/

Leave a Reply

Comment moderation is currently enabled so comments with spammy words or a few links might be delayed. Please do not submit your comments twice, they will be approved soon.
Off Auto TELEX VNI VIQR VIQR*