Enable mysql slow query log and run the mysqldumpslow command to check which SQL statement query is slow, that is, slow query slowlog. Now we will introduce how to enable this function. Add the following code under [mysqld]: long_query_time = 1log-slow-queries =/usr/local/mysql/data/slow. loglog-queries-not-using-indexeslong_query_time = 1 # define the Slow_queries variable for queries that exceed 1 second. Log-slow-queries =/usr/local/mysql/data/slow. log # defines the log Path for slow query. Log-queries-not-using-indexes # queries without indexes are recorded in slow query logs (optional ). Mysql comes with mysqldumpslow, a tool for viewing slow logs. Run mysqldumpslow -- h to view help information. This article mainly introduces two parameters-s and-t-s, which are sorting parameters. The options are: al: average lock time ar: Average number of returned records at: Average query time c: count l: Lock time r: return record t: Query time-t n show the first n records. Example: mysqldumpslow-s c-t 20 host-slow.logmysqldumpslow-s r-t 20 the preceding command shows the 20 most accessed SQL statements and the 20 most returned SQL record set. Mysqldumpslow-t 10-s t-g "left join" host-slow.log returns the first 10 SQL statements containing the left join according to time. With this tool, you can find out which SQL statements are performance bottlenecks and optimize them, such as adding indexes and implementing the application.