Preface MySQL slow query log is a function that we often encounter in our daily work. MySQL slow query log provides query information that exceeds the specified time threshold, which provides the main reference for performance optimization. It is a very practical function. The opening and configuration of MySQL slow query log is very simple. You can specify the recorded file (or table), and the time threshold exceeded can be recorded to the slow SQL. To be honest, compared with sqlserver trace or extended events (although the functions of these two are not just that), MySQL configuration always gives people a very refreshing feeling. 1. Opening the slow query log Under normal circumstances, you only need to add 2. By default, the time threshold for recording slow queries is 10s By default, when You can also explicitly specify the name of the slow query log file (it will be created automatically if it does not exist) and the time threshold for recording slow queries (non-default 10s). Note: When specifying long_query_time in the configuration file, no time unit is required, only a value, such as 1 for 1s. If a time unit is included, the service will not start. The following is an example of a slow SQL statement recorded in a log file: 3. Record slow query logs to a table Configuration: You need to add a log_output configuration to record slow queries in the table. There is a default slow_log table under the mysql library. You can directly set The recorded slow sql is as follows. It can be found that sql_text is a binary information, not the original sql text. You can use the CONVERT function to convert it. The difference between slow queries recorded in log files and in tables: 1. Slow queries are recorded in log files and tables. The records themselves are not much different. If they are recorded in tables, the execution time information of slow queries cannot be accurate to microseconds. 2. If the slow query information is recorded in a table, it is convenient for query. However, because it is structured data, it may be a little slower than recording it in a slow query log file (flat text file) (personal guess). If it is recorded in a file, the mysqldumpslow tool is required to parse it. 3. Slow query does not record failed queries. For example, if long_query_time is set to 10 (10 seconds), and a query takes more than 10 seconds but fails for other reasons, MySQL slow query will not be able to record this query information. Summarize The above is the full content of this article. I hope that the content of this article can bring some help to your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support of 123WORDPRESS.COM. You may also be interested in:
|
<<: Vue-CLI multi-page directory packaging steps record
>>: How to remove spaces or specified characters in a string in Shell
Vue router transitions are a quick and easy way t...
The main symptom of the conflict is that the FLASH...
Table of contents forEach() (ES6) method map() (E...
Result: Implementation code: html <div class=&...
Table of contents Preface What is data binding? T...
1. Download MySQL Community Server 5.6.35 Downloa...
The web color picker function in this example use...
The relationship between Tomcat logs A picture is...
lsof (list open files) is a tool to view files op...
Say goodbye to the past Before vscode had remote ...
During the Olympic Games, IE 8 Beta 2 will be rele...
This article example shares the specific code of ...
Vue data two-way binding principle, but this meth...
WML (Wireless Markup Language). It is a markup la...
Record the installation and use of openssh-server...