Long_query_time is the log of SQL that executes more than a few minutes, and here is 1 seconds.
Log-slow-queries and Slow_query_log_file settings where to write the log
Open the above parameters, run for a period of time, you can turn off, so as not to affect the production environment
Next is the analysis, my file here is called/var/log/mysql/slow.log.
Mysqldumpslow–help first, the main use is
-S order what to sort by (t, at, L, AL, R, AR etc), "at" is default
-T NUM just show the top n queries
The-G pattern grep:only Consider stmts the include this string
-S, is the order sequence, the description is not written in detail, mainly has
C,t,l,r and Ac,at,al,ar, sorted by query times, time, lock time, and the number of records returned, preceded by a in reverse order
-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
The above command shows the 20 SQL statements that have the most access and the 20 SQL that returns the recordset.
Mysqldumpslow-t 10-s t-g "left join"/var/log/mysql/slow.log
This is the time to return the first 10 of the SQL statement containing the left connection.
With this tool you can query the SQL statements are performance bottlenecks, to optimize, such as indexing, the implementation of the application, and so on.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.