How does mysql enable slow query to enable the mysql slow query log record bitsCN. the slow query log of commysql is very useful for queries with tracing problems. it can be used to analyze the resource-consuming SQL statements in the current program. how can I open the slow query log records of mysql?
In fact, it is very easy to open the slow query log of mysql, just in the mysql configuration file (windows system is my. ini, linux is my. the following code is added to [mysqld] of cnf:
Note:
The log-slow-queries setting writes the log in there. if it is null, the system will assign the host name to the slow query log and append the slow. log. /var/lib/mysql/slowquery. log is the location of the log storage file. Generally, this directory requires the write permission of the mysql running account. Generally, this directory is set to the mysql data storage directory.
2 in long_query_time = 2 indicates that the query takes more than two seconds to record.
If the log-long-format parameter is set, all queries without indexes will also be recorded. Add the following line to the file my. cnf or my. ini to record these queries.
This is a useful log. It has little impact on performance (assuming that all queries are fast), and emphasizes the most important queries (if indexes are lost or the indexes are not used properly)
# Time: 070927 8:08:52
# User @ Host: root [root] @ [192.168.0.20]
# Query_time: 372 Lock_time: 136 Rows_sent: 152 Rows_examined: 263630
Select id, name from manager where id in (66,10135 );
This is one of the slow query logs. it takes 372 seconds, locks 136 seconds, returns 152 rows, and queries 263630 rows in total.
If there is a lot of log content, it will be exhausting to look at it with one eye. mysql comes with an analysis tool, which is used as follows:
Enter the mysql/bin directory under the command line and enter mysqldumpslow
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service