Mysql (slow-query) Quick Method for enabling slow log query mysql has a function that can log down to run slow SQL statements. By default, www.2cto.com without this log opens my. ini, find [mysql] and add long_query_time = 2log-slow-queries = D:/mysql/logs/slow under it. log # Set to write logs there. It can be empty and the system will
A default file # log-slow-queries =/var/youpath/slow. in log linux, The host_name-slow.loglog-queries-not-using-indexes long_query_time is the length of time (in seconds) after which the SQL statement will be recorded, which is set to 2 seconds. Log-slow-queries sets the location of the log, which can be null. The system will give a default file
Host_name-slow.log, the generated log is literally in the mysql data DIRECTORY log-queries-not-using-indexes, record the query that does not use the index. The following describes common mysqldumpslow parameters. You can use mysqldumpslow-help to query them in detail. Www.2cto.com-s indicates the sorting method. c, t, l, and r indicate the number of records, time, query time, and returned
The number of records is sorted (from large to small). ac, at, al, and ar indicate the corresponding flashback. -T indicates the top n, that is, the number of previous data records returned. -G, followed by a regular expression matching mode, which is case insensitive. Next is to use mysql's built-in slow query tool mysqldumpslow analysis (mysql bin directory), I here the log file name is host-slow.log. List the 10 SQL statements with the most record times mysqldumpslow-s c-t 10 host-slow.log list the 10 SQL statements that return the record set up to mysqldumpslow-s r-t 10 host-slow.log returns the first 10 times by Time SQL statement mysqldumpslow-s t-t 10-g "left join" host-slow.log using mysqldumpslow command can be very clear to get a variety of query statements we need, query MySQL
The monitoring, analysis, and optimization of query statements are of great help.