MySQL slow query log analysis tool mysqldumpslow
Mysqldumpslow is a log analysis tool that comes with mysql. As the name suggests, mysqldumpslow is used to query SQL statements that are slow in query. This analyzes the causes of slow SQL query efficiency.
Generally, the results of the mysqldumpslow grouping query are similar. When displaying the statistical results, the numbers and strings can be abstracted into "N" and "S ". Of course, you can also use the-a and-n options to modify these abstract behaviors.
Mysqldumpslow query command
Mysqldumpslow [options] [log_file]
The following is an optional parameter (options) for mysqldumpslow:
-A: Do not abstract numbers into N, and strings into S.
Example:
Mysql % mysqldumpslow/home/mysql/logs/slow_query.log
Reading mysql slow query log from/home/mysql/logs/slow_query.log
Count: 1 Time = 0.00 s (0 s) Lock = 0.00 s (0 s) 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.00 s (0 s) Lock = 0.00 s (0 s) 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: The number is abstracted to at least the specified number of digits.
This article permanently updates the link address: