Mysqldumpslow is MySQL's own tool for analyzing slow queries.
Often use a few commands
-S order what to sort by (Al, in, AR, C, L, R, T), ' at ' is default
-T NUM just show the top n queries
The-G pattern grep:only Consider stmts the include this string
-R Reverse the sort order
-S, is the order sequence, mainly has
C,t,l,r and Ac,at,al,ar, respectively, are sorted by query times, query time, lock time, and number of records returned, preceded by a representative average of a
-T is the meaning of top N, which is to return the number of previous data
-G, you can write a regular matching pattern, case insensitive
Here are some examples
Here the n represents the number, and the different numbers can be represented as the same SQL statement
The above meaning is this 904 such statement, this statement maximum execution time 16.44s, altogether 14861s, the maximum lock 0.0.5 s, altogether locks the 45s
You can also use the-G option to use regular filtering
The-S at delegates are sorted by average query time