找时间通过PHP执行MySQL查询 [英] find time to execute MySQL query via PHP

查看:71
本文介绍了找时间通过PHP执行MySQL查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在互联网上看到了这个问题(此处此处),但我从未见过好的答案.是否有可能找到给定MySQL查询(通过mysql_query执行)通过PHP花费的时间?

I've seen this question around the internet (here and here, for example), but I've never seen a good answer. Is it possible to find the length of time a given MySQL query (executed via mysql_query) took via PHP?

某些地方建议使用php的microtime函数,但这似乎是不准确的. mysql_query可能由于网络延迟,系统响应缓慢或无法快速响应您的查询而陷入困境,或其他一些不相关的原因.这些都与您查询的质量没有直接关系,这是我真正要在此处进行测试的唯一内容. (如果您不同意,请在评论中提及!)

Some places recommend using php's microtime function, but this seems like it may be inaccurate. The mysql_query may be bogged down by network latency, or a sluggish system which isn't responding to your query quickly, or some other unrelated cause. None of these are directly related to the quality of your query, which is the only thing I really want to test out here. (Please mention in the comments if you disagree!)

推荐答案

我只检查查询本身的质量,然后从等式中删除PHP.使用类似 MySQL查询浏览器

I you are only checking the quality of the query itself, then remove PHP from the equation. Use a tool like the MySQL Query Browser or SQLyog.

或者,如果您具有外壳访问权限,则直接连接.这些方法中的任何一种在确定查询的实际性能方面都将是优越的.

Or if you have shell access, just connect directly. Any of these methods will be superior in determining the actual performance of your queries.

这篇关于找时间通过PHP执行MySQL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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