mysql> select * from test
+----+-------+
| id | name  |
+----+-------+
|  1 | david |
+----+-------+
1 row in set (0.00 sec)

如何精确到毫秒呢?MySQL有个内置语句(show profile)可以查看执行耗时。

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

然后执行查询语句。 使用show profiles就可以看到执行时间了。

mysql> show profiles;
+----------+------------+--------------------+
| Query_ID | Duration   | Query              |
+----------+------------+--------------------+
|        1 | 0.00034500 | select * from test |
+----------+------------+--------------------+
1 row in set (0.04 sec)

Duration就是该SQL的执行时间,将其乘以1000就是毫秒数了。

相关文章:

  • 2021-05-25
  • 2021-06-15
  • 2022-12-23
  • 2021-06-23
  • 2022-12-23
  • 2021-09-10
  • 2021-12-14
  • 2021-05-14
猜你喜欢
  • 2021-10-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-15
相关资源
相似解决方案