In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Let me tell you a little bit about mysql slow query view. Have you learned about similar topics before? If you are interested, let's take a look at this article. I believe it will be of some help to you after reading the mysql slow query.
MYSQL slow query
First, check the status of all the parameters of the system:
Mysql > show variables
2. View the definition of slow query:
Mysql > show variables like'% quer%'
| | log_slow_queries | ON |
| | long_query_time | 5.000000 | |
Mysql > show variables like 'slow%'
+-- +
| | Variable_name | Value |
+-- +
| | slow_launch_time | 5 | |
| | slow_query_log | ON |
| | slow_query_log_file | / var/log/mysql/slow_query_log |
+-- +
3 rows in set (0.00 sec)
3. Modify the definition of slow query:
1. Modify now:
Enable slow query function, time definition
Mysql > SET log_slow_queries=on
Mysql > SET long_query_time=5
Enable slow query record function, time definition, file storage location
Mysql > SET slow_query_log=on
Mysql > SET slow_launch_time=5
Mysql > SET slow_query_log_file=/var/log/mysql/slow_query_log
two。 Modify the configuration file (need to restart the service)
Vim / etc/my.cnf
Enable slow query function, time definition
Log_slow_queries=on | off
Long_query_time=5
Enable slow query record function, time definition, file storage location
Slow_query_log=on | off
Slow_launch_time=5
Slow_query_log_file=/var/log/mysql/slow_query_log
Restart the service
Service mysql restart
IV. Other settings
1. Record all queries that do not use the index
Log_queries_not_using_indexes=on | off
two。 Record slow queries caused by more than 1000 searches
Min_examined_row_limit=1000
3. Record those slow OPTIMIZE TABLE,ANALYZE TABLE and ALTER TABLE statements
Log-slow-admin-statements
4. Record slow queries generated by slave
Log-slow-slave-statements
Log analysis tool mysqldumpslow
-s, which indicates how to sort:
C: access count
L: lock time
R: returns the record
T: query time
Al: average lock time
Ar: the average number of records returned
At: average query time
-t, which means top n, that is, how many previous pieces of data are returned.
-g, a regular matching pattern can be written later, which is case-insensitive.
Example:
1. Get the top 10 SQL that returns the recordset.
Mysqldumpslow-s r-t 10 / var/log/mysql/slow_query_log/mysql06_slow.log
two。 Get the 10 most visited SQL
Mysqldumpslow-s c-t 10 / var/log/mysql/slow_query_log/mysql06_slow.log
3. Get the query statements with left links in the first 10 items sorted by time.
Mysqldumpslow-s t-t 10-g "left join" / var/log/mysql/slow_query_log/mysql06_slow.log
4. It is also recommended to use these commands in combination with | and more, otherwise screen brushing may occur.
Mysqldumpslow-s r-t 20 / var/log/mysql/slow_query_log/mysql06-slow.log | more
What do you think of the mysql slow query to see what this article is like and whether it has gained anything? If you want to know more about it, you can continue to follow our industry information section.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.