如何在Wordpress网站上显示数据库查询统计信息? [英] How do I display database query statistics on Wordpress site?

查看:286
本文介绍了如何在Wordpress网站上显示数据库查询统计信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经注意到,一些Wordpress博客的页脚中存在查询统计信息,这些统计信息仅说明查询的数量以及处理特定页面所需的总时间,例如:

I've noticed that a few Wordpress blogs have query statistics present in their footer that simply state the number of queries and the total time required to process them for the particular page, reading something like:

23个查询. 0.448秒

23 queries. 0.448 seconds

我想知道这是如何实现的.是通过使用特定的Wordpress插件还是通过在页面代码中使用某些特定的php函数?

I was wondering how this is accomplished. Is it through the use of a particular Wordpress plug-in or perhaps from using some particular php function in the page's code?

推荐答案

尝试将其添加到模板页脚的底部:

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'); ?>

这篇关于如何在Wordpress网站上显示数据库查询统计信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆