MySQL MySQL的慢查询日志中的时间单位是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6936593/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 20:44:09  来源:igfitidea点击:

What is the unit of time in MySQL's slow-query log?

mysqllogging

提问by aroth

I'm looking at the slow query log from a drupal-based webapp, and have lines that look like this:

我正在查看来自基于 drupal 的 web 应用程序的慢查询日志,并且有如下所示的行:

# Query_time: 3257  Lock_time: 0  Rows_sent: 272  Rows_examined: 272
# Query_time: 1654  Lock_time: 0  Rows_sent: 222  Rows_examined: 222
# Query_time: 3292  Lock_time: 0  Rows_sent: 269  Rows_examined: 269
# Query_time: 1029  Lock_time: 0  Rows_sent: 172  Rows_examined: 172
# Query_time: 2126  Lock_time: 0  Rows_sent: 251  Rows_examined: 251
# Query_time: 1731  Lock_time: 0  Rows_sent: 229  Rows_examined: 229

Are these times indicating that the associated queries took between 1 and 3+ seconds (slow but not terrible) to execute, or between 1,000 and 3,000+ seconds (completely unacceptable)? I understand that the long_query_timeoption is specified in seconds, but do the log messages follow this same convention, or do they use milliseconds instead?

这些时间是否表明相关查询的执行时间在 1 到 3+ 秒之间(缓慢但并不可怕),或者在 1,000 到 3,000+ 秒之间(完全不可接受)?我知道该long_query_time选项以秒为单位指定,但日志消息是否遵循相同的约定,还是使用毫秒?

Edit: this is with MySQL version 5.0.45.

编辑:这是 MySQL 5.0.45 版。

采纳答案by Mchl

It's in seconds. The 'resolution of microseconds' means, that you can have up to microsecond precision after a decimal (although AFAIK it need a patch to actually write with such precision)

它在几秒钟内。“微秒分辨率”意味着,您可以在小数点后获得高达微秒的精度(尽管 AFAIK 它需要一个补丁才能以这种精度实际写入)

https://github.com/wvanbergen/request-log-analyzer/wiki/MySQL-slow-query-log

https://github.com/wvanbergen/request-log-analyzer/wiki/MySQL-slow-query-log

回答by jcisio

Only since MySQL 5.1.21 that you can specify a decimal value and has a resolution of microsecond. http://dev.mysql.com/doc/refman/5.1/en/slow-query-log.html

仅从 MySQL 5.1.21 开始,您可以指定十进制值并具有微秒分辨率。 http://dev.mysql.com/doc/refman/5.1/en/slow-query-log.html