Edit the my. cnf or my. ini file and remove the comments of the following lines of code:Copy codeThe Code is as follows:Log_slow_queries =/var/log/mysql/mysql-slow.log.Long_query_time = 2Log-queries-not-using-indexes This will record slow queries
In web development, we often write some SQL statements. A bad SQL statement may make your entire program very slow. After 10 seconds, users usually choose to close the webpage, how to optimize SQL statements to find out SQL statements that have been
The most basic is mysql's mysqlslowdump
Easy to use:
Mysqldumpslow-s c-t 20 host-slow.log
Parameters:
1.-s, sorting, c, t, l, r, and ac, at, al, and ar are sorted by query times, time, lock time, and returned records respectively. Adding a is
Slow Query Optimization of MySQL is a common topic. This article describes the actual problems encountered in the production database and provides examples.
Enable slow query supportFirst, activate the slow query log, modify the my. CNF
Enable the slow query record function. Next, let's analyze the content of the slow query:
Select count (distinct. name) from cp_paycard as a left join cp_reservation as B on. uid = B. UID where. type = 2 and B. cpparkid = '000000' and B.
As the data volume continues to grow, performance is particularly important. Perhaps after optimization and good solutions, you cannot feel the existence of performance problems, but as the data volume continues to grow,
From millions to tens of
Discuz is slow. when MySQL is frequently rushed to MySQL 100%, find the cause. Here, we will first write down the slow query log of MySQL on a Windows host, as shown below:Run the CMD command line in the bin directory of MySQL. net stop mysql. Find
In web development, we often write some SQL statements. A bad SQL statement may make your entire program very slow. After 10 seconds, users usually choose to close the webpage, how to optimize SQL statements to find out SQL statements that have been
MySQL itself supports slow query logging, which can be configured to log queries that exceed a specific time in SQL queries. This is a very effective tool in optimizing SQL queries to help us quickly locate the SQL that has the problem. Variables
First, the concept part:As the name implies, the slow query log is a long execution of query, which is what we often call slow query, by setting--log-slow-queries[=file_name] to open the function and set the record location and file name, The
MySQL has a log, called the slow query log , is mainly used to record some time-consuming queryFor With this log we can analyze what operations are impacting performance, and we need toPerform some optimization measures.View open StatusAbove is the
1 Slow query definitionmeans that MySQL logs all SQL statements that execute a time threshold that exceeds the Long_query_time parameter setting. The slow query log is the log that logs these SQL.2 Turn on slow query logLocate the MySQL
Mysqlsla is a MySQL log analysis tool launched by hackmysql.com, which is very powerful. Data reports are very useful for analyzing the causes of slow queries, including frequency of execution, amount of data, query consumption, etc.First, use
MySQL Slow queryFirst, check the system all parameter status:Mysql> Show variablesSecond, see the definition of slow query:Mysql> Show variables like '%quer% ';| log_slow_queries | On || Long_query_time | 5.000000 |Mysql> Show variables like ' slow%
=========================================================Method One: This method I am using, hehe, compare like this kind of instant sex.Versions above Mysql5.0 can support the recording of slower-performing SQL statements.Mysql> Show variables like
MySQL's "slow query" refers to an SQL statement that exceeds the maximum allowable query time ( long_query_time ), and the "unused index" query, by definition, is the SQL statement that the query statement does not use to the index.Slow query
First, open the slow query log1. Query slow query time default 10 seconds like "Long_query_time"2. Query slow query log file address like "%slow%"3. If the slow query log is not turned on, configure the item under My.ini [MYSQLD] and restart the
Briefly:The method of analyzing the performance of MySQL statement query in addition to using the EXPLAIN output execution plan, you can also let the MySQL record query over a specified time of the statement, we will exceed the specified time of the
Slow query log: all SQL statements that run longer than long_query_time in MySQL slow query log records help you find slow SQL statements, so that we can optimize these SQL statements. Slow query log configuration: by default, mysql does not enable
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.