1.MySQL 5.5 command line inside
Copy Code code as follows:
Set global log_slow_queries = on; # Open Slow Log
Set [Session|global] long_query_time = 0.2 # setting time. Precise milliseconds
Set global log_queries_not_using_indexes = on; # set up a query without indexes
2. View the form of the store log
Mysql> Show variables like ' log_output ';
This file is meant to be stored in the form of a file.
If it is a table, it is stored in the system tables. Mysql.slow_log the table.
Use set global log_output= ' table '; Variable change
3. View the location of the slow log file (in file form)
4. Use the Mysqldumpslow command to view the slow log.
Detailed applicable mysqldumpslow-help query.
Parameter description:
-S, which means that the C, T, L, and R are sorted by record count, time, query time, number of records returned, AC, at, AL, AR, and the corresponding flashbacks.
-T is the meaning of top N, which returns the number of previous data.
-G, a regular matching pattern can be written behind, and case insensitive.
Mysqldumpslow-s c-t Host-slow.log
Lists the 10 SQL statements that return the largest recordset
Mysqldumpslow-s r-t Host-slow.log
Return the first 10 SQL statements containing the left connection in the time
Mysqldumpslow-s t-t 10-g "left join" Host-slow.log