本文共 1204 字,大约阅读时间需要 4 分钟。
mysqldumpslow是mysql自带的一种慢查询日志分析工具,顾名思义,就是查询那些出那些查询慢的SQL语句,由此分析出SQL查询效率慢的原因。
通常来说,mysqldumpslow分组查询的结果是相似的,它在展示统计结果时,可以将数字和字符串分别抽象成“N”和“S”。当然也可以用-a 和 -n选项可以用来修改这些抽象的行为。
mysqldumpslow查询命令
mysqldumpslow [options] [log_file]
mysqldumpslow可选参数(options),如下:
-a : 不将数字抽象成N,字符串抽象成S。
示例:
mysql%mysqldumpslow /home/mysql/logs/slow_query.log
Reading mysql slow query log from /home/mysql/logs/slow_query.log Count: 1 Time=0.00s (0s) Lock=0.00s (0s) Rows=0.0 (0), FAVDBA[FAVDBA]@[10.1.45.51] # Schema: Last_errno: N Killed: N # Query_time: N.N Lock_time: N.N Rows_sent: N Rows_examined: N Rows_affected: N # Bytes_sent: N SET timestamp=N; SELECT EVENT_NAME, EVENT_SCHEMA, EVENT_DEFINITION FROM INFORMATION_SCHEMA.EVENTS |
mysql%mysqldumpslow -a /home/mysql/logs/slow_query.log
Reading mysql slow query log from /home/mysql/logs/slow_query.log Count: 1 Time=0.00s (0s) Lock=0.00s (0s) Rows=0.0 (0), FAVDBA[FAVDBA]@[10.1.45.51] # Schema: Last_errno: 0 Killed: 0 # Query_time: 0.004095 Lock_time: 0.002907 Rows_sent: 0 Rows_examined: 0 Rows_affected: 0 # Bytes_sent: 140 SET timestamp=1451270206; SELECT EVENT_NAME, EVENT_SCHEMA, EVENT_DEFINITION FROM INFORMATION_SCHEMA.EVENTS |
-n N : 将数字抽象显示成至少指定的位数
转载地址:http://oeajx.baihongyu.com/