当前位置:网站首页>MySQL tuning -- 02 -- slow query log
MySQL tuning -- 02 -- slow query log
2022-06-25 05:49:00 【High high for loop】
Tips : When the article is finished , Directories can be generated automatically , How to generate it, please refer to the help document on the right
List of articles
Slow query log

1. Enable the slow query log parameter
1.1 Turn on slow_query_log


1.2 modify long_query_time threshold



2. View the number of slow queries



3. Slow query log analysis tool :mysqldumpslow



3.1 give an example



3.2 Common references for work :

4. Turn off slow query log
MySQL There are two ways for the server to stop the slow query log function :
The way 1: Permanent way

The way 2: Temporary way

5. Delete slow query log

Slow query case
Table structure
CREATE TABLE `person_info_large` (
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`account` VARCHAR (10),
`name` VARCHAR (20),
`area` VARCHAR (20),
`title` VARCHAR (20),
`motto` VARCHAR (50),
PRIMARY KEY (`id`),
UNIQUE(`account`),
KEY `index_area_title`(`area`,`title`)
) ENGINE = INNODB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8
run
- The data here is 200W strip . Note the table structure , Just remember which fields have indexes , The following analysis will focus on this table .

This 3.36s Not the actual execution time , The actual execution time has to be slow. Check the log Query_time Parameters
Slow query log files

You can see Query_time: 6.337729s, More than the 1s, So it will be recorded
- Be careful : Some slow queries are executing , As a result, the database has been overloaded , However, due to the slow speed, the query has not been executed yet , Therefore, the slow query log cannot see any statements , You can use show processlist Command to view the slow query being executed .show processlist Show which threads are running , If there is PROCESS jurisdiction , You can see all threads . otherwise , You can only see the current session thread .
Parameter description
- Time: The time when the slow query occurred
- Query_time: Query time
- Lock_time: Time waiting to lock the watch
- Rows_sent: The number of rows returned by the statement
- Rows_exanined: Number of rows read from the storage engine during statement execution

concerns


Focus on : Rows_exanined Number of scanning lines / Rows_sent Returns the number of rows
边栏推荐
- Create a complete binary tree in array order
- Farewell to Lombok in 996
- What is the use of the subprocess module
- Classic usage of the sumproduct function
- 2.20 learning content
- BUUCTF(web:1-50)
- How the sap ui5 framework performs single step debugging of batch requests
- Pytorch- daily learning notes of some small functions involving training
- Vscode voice notes to enrich information (Part 1)
- Fundamentals of C language
猜你喜欢
The locally developed SAP ui5 application is deployed to the ABAP server to perform error analysis

Timed thread pool

2.20 learning content

Create a complete binary tree in array order

Multithreading and thread pool

JSON Library Tutorial from scratch (I): starting to learn and organize notes

Use of MySQL variables

Deep learning non local neural networks
![[Huawei machine test] hj16 shopping list](/img/54/d28f5aea9350af7797ca7c069e564d.jpg)
[Huawei machine test] hj16 shopping list
Yunda's cloud based business in Taiwan construction 𞓜 practical school
随机推荐
What happens when you use "-fno exceptions", "new T"- With “-fno-exceptions”, what happens with “new T”?
Transformations of pytorch torch torch vision
"APEC industry +" biov Tech talks about the cross-border of Chinese biotechnology enterprises and "Pratt & Whitney Kangyu" | apec-hub public welfare
Go implements LRU cache
The simplest way to tell you is to hash and not hash
Day17 (set)
Day16 (regular expression, enumeration)
Analysis of IM project framework
Differences and connections between sap ui5 and openui5
First blog
Voxel based and second network learning
Jenkins installation and configuration
Ethernet
What is the use of the subprocess module
Configuration file ui5 local in SAP ui5 tools Configuration points of yaml
Learn the interface test, see it is very good, and make a note
Code learning-cvpr2020 unsupervised domain adaptive semantic segmentation: intra advance
Deep analysis of recursion in quick sorting
Pytorch- daily learning notes of some small functions involving training
ERDAS 9.2 installation tutorial