热线电话:13121318867

登录
2019-02-25 阅读量: 687
怎样获得mysql处理一个sql文件所用的毫秒数?

问题描述:

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

解决方法:

如果想要更精确的查询时间 ... 你需要开启 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)
0.0000
3
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子