phpMyAdmin - Query Execution Time(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 - 查询执行时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:phpMyAdmin - 查询执行时间
基础教程推荐
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- 在多列上分布任意行 2021-01-01
- oracle区分大小写的原因? 2021-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
