MySQL slow query: enabling slow query and mysql Query
1. What is the use of slow queries?
It records all SQL statements that have been executed longer than long_query_time, and helps you find slow SQL statements to optimize these SQL statements.
Ii.
MySQL slow Query
Slow query (slow log)It can help us locate specific SQL statements for SQL statement optimization. For example, slow query logs record the SQL statements whose execution time exceeds the given value, so as to locate the
1. How to enable slow query for MySQL in Windows:
The configuration file of MySQL in Windows is usually my. ini, and the path of my path is c: \ mysql \ My. ini. You can find
Compile my. ini and add it under [mysqld]
Log-Slow-queries= D: \ mysql \
MySQL version is mysql5.6.22, installation environment Windows7.1. Use this query log to find SQL statements of efficiency problems and record them for monitoring.You can query and set the slow query log using the following statement(1) Check if the
MySQL Slow log is often the problem of locating SQL performance. Index usage can be adjusted by slow log analysis. This is one of the most used features.
At present, MySQL also supports the slow logging below the millisecond level, this feature has
In web development, we often write some SQL statements, a bad SQL statement may make your entire program is very slow, more than 10 seconds, the average user will choose to close the page, how to optimize the SQL statements to run longer time SQL
1,Https://github.com/Meituan-Dianping/SQLAdvisor/blob/master/doc/QUICK_START.mdhttp://www.ttlsa.com/mysql/meituan-sql-optimization-tool-sqladvisor/Enter the command in the MySQL client:Show variables like '%quer% ';The options for the red box
First, Introduction to open the slow query log, you can let the MySQL record query over a specified time of the statement, through the location analysis performance bottlenecks, to better optimize the performance of the database systemSecond,
First, simple installationwget percona.com/get/pt-query-digestchmoe u+x pt-query-digestSecond, simple useMoreReference article: Http://blog.itpub.net/29773961/viewspace-2024992/pt-query-digest is a set of tools to help DBAs manage MySQL
Turn from:MySQL Slow log query full parse: From parameters, configuration to analysis tools-mysql-dbaplus community-around the database, big data, PAAs Cloud, the most focused on the "data" of the learning communication and professional
Related parameters of a slow logLong_query_time: Set the threshold of the slow query, the SQL that exceeds the sub-set value is logged to the slow query log, the default value is 1sLOG_SLOW_QUERIES:1/0 Specifies whether to turn on the slow query log
Input command:show variables like ' slow% 'You can find that Slow_query_log is OFF (default), indicating that the slow query log is not turned onSlow_query_log_file for slow query log fileThere are two ways to turn on the slow query logMethod One:
First, log cuttingPrinciple:1, CP a slow log backup2, clear the principle of slow log3, write a script, every day, so OKSecond, find the slow log in the log1, do a log cutting (slow log file is small)2. Find a slow log at a timeLog Time format: #
First, IntroductionPt-query-digest is a tool for analyzing slow queries for MySQL, which analyzes Binlog, general log, Slowlog, It can also be analyzed using showprocesslist or MySQL protocol data crawled by tcpdump. The analysis results can be
First, IntroductionTurn on the slow query log, you can let the MySQL record query over a specified time of the statement, through the location analysis of performance bottlenecks, to better optimize the performance of the database system.Second,
Initial: Due to the high CPU consumption of the newly installed server, the response is not timely troubleshooting, because the environment based on the most basic lamp architectureThink of turning on MYSQL slow_query_log slow query log for reasons
Pt-query-digest although powerful, but after all, there is no visual display of the Web interface, we can use Anemometer as the display of pt-query-digest execution results, Anemometer is an open source software developed specifically for MySQL's
Instant Analysis:Show full percesslist;Turn on the slow query log and analyze the log records:Long_query_time = 1Log-slow-queries =/data/3306/slow.logLog_queries_not_using_indexesSplit log sent to mailboxAdd explain to see how the statement is
The MySQL version number is mysql5.6.22. Installation Environment Windows7.1. Use this query log to find SQL statements that have an efficiency problem. and record them and monitor them.Ability to query and set slow query logs using, for example,
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.