In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain in detail what the mysql slow query log is, and the editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
Definition: a logging function provided by mysql, which is used to record sql statements in which the corresponding time of mysql exceeds the long_query_ time value. The default value of long_query_time is 10 seconds, and SQL with a corresponding time of more than 10 seconds will be recorded in the log.
1. Check the status of the slow log feature, which is turned off by default
Show variables like'% slow_query_log%'
OFF indicates that slow logging is turned off, slow logging is stored in the DESKTOP-2331B4V-slow.log file, and DESKTOP is my computer name.
2. Enable slow log function
Set global slow_query_log=1
Then query the slow log status
The status is ON, which indicates that the slow log feature is enabled.
3. View the default long_query_time time
The long_query_time is 10 seconds, which means that only if the SQ statement exceeds 10 seconds will it be recorded in the slow log.
4. Set the long_query_time duration. The default 10 seconds is too long.
Set global long_query_time=3
Re-open a session, and if it is a window system, you can clock in another cmd (note that if you are still querying the long_query_time length in the session that sets the long_query_time, it is still 10 seconds by default, so restart a session), and query the long_query_time duration again
5. Simulation time-consuming sql
The sql statement indicates that the query took 5 seconds, exceeding the set long_query_time duration. And then open it.
DESKTOP-2331B4V-slow.log log, the contents are as follows: MySQL, Version: 5.5.60 (MySQL Community Server (GPL)). Started with:TCP Port: 3306, Named Pipe: MySQLTime Id Command Argument# Time: 180729 12 MySQLTime Id Command Argument# Time 52 User@Host: root [root] @ localhost [127.0.0.1] # Query_time: 5.005746 Lock_time: 0.000000 Rows_sent: 1 Rows_examined: 0SET timestamp=1532839949;select sleep (5)
As you can see, the timed-out SQL has been written to the slow log.
When there are many slow logs, you can also query the number of entries in the slow logs.
6. Configuration
The above example is configured with a command. If the database is restarted, the configuration becomes invalid. If you want to restart and the configuration is still valid, you can add the configuration command in * * mysqld * * under my.ini:
This is the end of slow_query_log=1slow_query_log_file=d:/mysql/my.loglong_query_time=3long_output=FILE 's article on "what is the mysql slow query log". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.