4.6.10 mysqldumpslow — Summarize Slow Query Log Files汇总慢速查询日志文件

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 NameDescription
-aDo not abstract all numbers to N and strings to 'S'不要将所有数字抽象为N,将字符串抽象为'S'
-nAbstract numbers with at least the specified digits至少包含指定数字的抽象数字
--debugWrite debugging information写入调试信息
-gOnly consider statements that match the pattern只考虑与模式匹配的语句
--helpDisplay help message and exit显示帮助消息并退出
-hHost name of the server in the log file name日志文件名中服务器的主机名
-iName of the server instance服务器实例的名称
-lDo not subtract lock time from total time不要从总时间中减去锁定时间
-rReverse the sort order颠倒排序顺序
-sHow to sort output如何对输出进行排序
-tDisplay only first num queries仅显示第一个num查询
--verboseVerbose mode详细模式