怎样获得mysql处理一个sql文件所用的毫秒数?
迷茫
迷茫 2017-04-17 11:08:25
[MySQL讨论组]

比如:source schema.sql; schema.sql中含有超过100条insert命令(所以profile基本上就用不着了),我要怎么才能知道处理这个文件用了多少毫秒呢?

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

全部回复(1)
迷茫

你没办法把默认的那个显示时间改成毫秒 ...

如果想要更精确的查询时间 ... 你需要开启 Profile ... 方法如下 ...

mysql> set profiling=1;
Query OK, 0 rows affected (0.00 sec)

mysql> select * from bigtable;
29121487 rows in set (0.00 sec)

mysql> show profiles;
+----------+------------+--------------------+
| Query_ID | Duration   | Query              |
+----------+------------+--------------------+
|        1 | 0.00026925 | select * from user |
+----------+------------+--------------------+
1 row in set (0.00 sec)

mysql> show profile;
+--------------------------------+----------+
| Status                         | Duration |
+--------------------------------+----------+
| starting                       | 0.000020 |
| Waiting for query cache lock   | 0.000005 |
| checking query cache for query | 0.000028 |
| checking permissions           | 0.000008 |
| Opening tables                 | 0.000019 |
| System lock                    | 0.000011 |
| init                           | 0.000033 |
| optimizing                     | 0.000006 |
| statistics                     | 0.000010 |
| preparing                      | 0.000009 |
| executing                      | 0.000004 |
| Sending data                   | 0.000078 |
| end                            | 0.000006 |
| query end                      | 0.000003 |
| closing tables                 | 0.000008 |
| freeing items                  | 0.000016 |
| logging slow query             | 0.000004 |
| cleaning up                    | 0.000005 |
+--------------------------------+----------+
18 rows in set (0.00 sec)

mysql> 

这是不错的性能分析器 ... 相关的资料也不少 ... 知道关键字之后自己看看吧 ...

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号