MySQL provides a slow log analysis tool mysqldumpslow
View mysqldumpslow help
mysqldumpslow --help
1 [root@localhost~]# mysqldumpslow --help 2 Usage: mysqldumpslow [ OPTS... ] [ LOGS... ] 3 4 Parse and summarize the MySQL slow query log. Options are 5 6 --verbose verbose 7 --debug debug 8 --help write this text to standard output 9 10 -v verbose 11 -d debug 12 -s ORDER what to sort by (al, at, ar, c, l, r, t), 'at' is default 13 al: average lock time 14 ar: average rows sent 15 at: average query time 16 c: count 17 l: lock time 18 r: rows sent 19 t: query time 20 -r reverse the sort order (largest last instead of first) 21 -t NUM just show the top n queries 22 -a don't abstract all numbers to N and strings to 'S' 23 -n NUM abstract numbers with at least n digits within names 24 -g PATTERN grep: only consider stmts that include this string 25 -h HOSTNAME hostname of db server for *-slow.log filename (can be wildcard), 26 default is '*', i.e. match all 27 -i NAME name of server instance (if using mysql.server startup script) 28 -l don't subtract lock time from total time
. 1 - S, which is a sorted manner 2 . 3 C: access count . 4 . 5 . 6 . 7 L: lock time . 8 . 9 10 . 11 R & lt: Returns the record 12 is 13 is 14 15 T: Time Query 16 . 17 18 is . 19 Al: Average locking time 20 is 21 is 22 is 23 is Ar: the average number of records returned 24 25 26 is 27 AT: average query time 28 29 30 31 is - T, is the top n meaning, that is how many of the return to the previous data; 32 33 is - G, can be written behind a regular pattern matching, case-insensitive; 34 is 35 36 37 [ example: 38 is 39 to give up the return record set 10 SQL. 40 41 is the mysqldumpslow -SR 10 -t / Database / MySQL / mysql06_slow.log 42 is 43 is 44 is 45 to give the most accessed 10 the SQL 46 is 47 the mysqldumpslow -SC 10 -t / Database / MySQL / mysql06_slow.log 48 49 50 51 is obtained according to 10 before which time sorting containing query left connected. 52 53 mysqldumpslow -st -g -t 10 "left the Join" / Database / MySQL / mysql06_slow.log 54 55 56 57 In addition the proposed combination when using these commands | and more, otherwise there may be cases scraper appear. 58 59 mysqldumpslow -s r -t 20 /mysqldata/mysql/mysql06-slow.log | more
Reference Links: https://blog.csdn.net/zlb_lover/article/details/81284267