phpMyAdmin-查询执行时间 [英] phpMyAdmin - Query Execution Time

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

问题描述

当我在phpMyAdmin中执行一个简单的语句时,

When I execute a simple statement in phpMyAdmin like

SELECT *
FROM a

其中"a"有500'000行,它使我在本地主机上的时间只有几毫秒.

where "a" has 500'000 rows, it gives me a time of a few milliseconds on my localhost.

某些复杂的查询报告的时间要长得多(如预期的那样),但有些查询的报告时间也非常快< 1/100s,但是phpMyAdmin中的结果页面显示时间更长.

Some complex queries report times that are way longer (as expected), but some queries report also very fast times < 1/100s but the result page in phpMyAdmin takes way longer to display.

所以我不确定,在phpMyAdmin中显示的执行时间是否真实和准确?如何测量?它会使用所有子选择,联接等来衡量整个查询吗?

So I'm unsure, is the displayed execution time really true and accurate in phpMyAdmin? How is it measured? Does it measure the whole query with all subselects, joins etc?

谢谢!

更新

我认为最好用自己的PHP脚本进行测试,例如:

I thought it'd be a good idea to test from my own PHP-script like:

$start = microtime(true);
$sql = "same statement as in phpMyAdmin";
$db = new PDO('mysql:host=localhost;dbname=mydb', 'root', 'lala');
$statement = $db -> prepare($sql);
$statement -> execute();
echo microtime(true) - $start . ' seconds';

,对于相同的0.005s语句,与phpMyAdmin中报告的时间相比,该过程要花费超过7秒的时间. 该查询返回300'000行,如果我使用"LIMIT 0,50"将其限制为50行,则该行小于1/100s.这种差异从何而来?我不会遍历返回的对象或其他东西.

and that takes more than 7 seconds compared to a reported time in phpMyAdmin for the same statement of 0.005s. The query returns 300'000 rows, if I restrict it to 50 with "LIMIT 0,50" it's under 1/100s. Where does that difference come from? I don't iterate over the returned objects or something...

推荐答案

显示的执行时间是查询在服务器上运行所花费的时间-它是准确的,并且来自MySQL引擎本身.不幸的是,结果必须随后通过网络发送到您的浏览器才能显示,这需要花费更长的时间.

The displayed execution time is how long the query took to run on the server - it's accurate and comes from the MySQL engine itself. Unfortunately, the results have to then be sent over the web to your browser to be displayed, which takes a lot longer.

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

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