The MySQL slow query log contains information about queries that take a long time to execute (see Section 5.4.5, “The Slow Query Log”). mysqldumpslow parses MySQL slow query log files and summarizes their contents.MySQL慢速查询日志包含有关执行时间较长的查询的信息(请参阅第5.4.5节,“慢速查询日志”)。mysqldumpslow解析MySQL慢速查询日志文件并总结其内容。
Normally, mysqldumpslow groups queries that are similar except for the particular values of number and string data values. 通常,mysqldumpslow会将除了数字和字符串数据值的特定值之外相似的查询分组。It “abstracts” these values to 在显示摘要输出时,它将这些值“抽象”为N
and 'S'
when displaying summary output. To modify value abstracting behavior, use the -a
and -n
options.N
和'S'
。要修改值抽象行为,请使用-a
和-n
选项。
Invoke mysqldumpslow like this:像这样调用mysqldumpslow:
mysqldumpslow [options
] [log_file
...]
Example output with no options given:未给出选项的示例输出:
Reading mysql slow query log from /usr/local/mysql/data/mysqld80-slow.log Count: 1 Time=4.32s (4s) Lock=0.00s (0s) Rows=0.0 (0), root[root]@localhost insert into t2 select * from t1 Count: 3 Time=2.53s (7s) Lock=0.00s (0s) Rows=0.0 (0), root[root]@localhost insert into t2 select * from t1 limit N Count: 3 Time=2.13s (6s) Lock=0.00s (0s) Rows=0.0 (0), root[root]@localhost insert into t1 select * from t1
mysqldumpslow supports the following options.mysqldumpslow支持以下选项。
Table 4.23 mysqldumpslow Options选项
Option Name | Description |
---|---|
-a | |
-n | |
--debug | |
-g | |
--help | |
-h | |
-i | |
-l | |
-r | |
-s | |
-t | |
--verbose |
Display a help message and exit.显示帮助消息并退出。
Do not abstract all numbers to 不要将所有数字抽象为N
and strings to 'S'
.N
,将字符串抽象为'S'
。
--debug
, -d
Run in debug mode.在调试模式下运行。
This option is available only if MySQL was built using 仅当MySQL使用WITH_DEBUG
. MySQL release binaries provided by Oracle are not built using this option.WITH_DEBUG
构建时,此选项才可用。Oracle提供的MySQL发布二进制文件不是使用此选项构建的。
Consider only queries that match the (grep-style) pattern.只考虑与(grep样式)模式匹配的查询。
Host name of MySQL server for MySQL服务器的主机名为*-slow.log
file name. *-slow.log
文件名。The value can contain a wildcard. 该值可以包含通配符。The default is 默认值为*
(match all).*
(全部匹配)。
Name of server instance (if using mysql.server startup script).服务器实例的名称(如果使用mysql.server
启动脚本)。
Do not subtract lock time from total time.不要从总时间中减去锁定时间。
Abstract numbers with at least 名称中至少包含N
digits within names.N
位数字的抽象数字。
Reverse the sort order.颠倒排序顺序。
How to sort the output. The value of 如何对输出进行排序。sort_type
should be chosen from the following list:sort_type
的值应从以下列表中选择:
t
, at
: Sort by query time or average query time:按查询时间或平均查询时间排序
l
, al
: Sort by lock time or average lock time:按锁定时间或平均锁定时间排序
r
, ar
: Sort by rows sent or average rows sent:按发送的行或平均发送的行排序
c
: Sort by count:按计数排序
By default, mysqldumpslow sorts by average query time (equivalent to 默认情况下,mysqldumpslow按平均查询时间排序(相当于-s at
).-s at
)。
Display only the first 在输出中仅显示前N
queries in the output.N
个查询。
--verbose
, -v
Verbose mode. Print more information about what the program does.详细模式。打印有关程序功能的更多信息。