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

查看:55
本文介绍了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/100 秒,但 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';

与 phpMyAdmin 中报告的 0.005 秒相同语句的时间相比,这需要超过 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天全站免登陆