Home > Database > Mysql Tutorial > body text

Introduction to MySQL slow query operations for Mysql optimization

黄舟
Release: 2017-08-01 15:08:42
Original
1346 people have browsed it

MySQL's slow query is a logging function provided by MySQL, which is used to record sql statements that exceed a certain time limit.

You need to define this time limit yourself. A SQL statement that exceeds this time limit is a relatively slow SQL statement. This statement will be recorded in the log file for easy viewing and optimization.

mysql slow query use

1. MySQL configuration file is required (restart the MySQL server)

Introduction to MySQL slow query operations for Mysql optimization

2. Simple test:

1. Add a table with a single record of about 4 million

Introduction to MySQL slow query operations for Mysql optimization

3. Structure: no_index character is not indexed

Introduction to MySQL slow query operations for Mysql optimization

4. The test is done on the structure without indexing A simple query found that the SQL statement was recorded in the slow query log.

Introduction to MySQL slow query operations for Mysql optimization

5. Test after no_index indexing:

Introduction to MySQL slow query operations for Mysql optimization

6. Use this statement to view the structure in the table

Introduction to MySQL slow query operations for Mysql optimization

Introduction to MySQL slow query operations for Mysql optimization

7. Testing after adding the index, it was found that after using the index, the query efficiency is significantly accelerated

Introduction to MySQL slow query operations for Mysql optimization

8. Through a simple comparison test, it was found that slow queries can record SQL statements that exceed a certain time limit. The comparison found that in general, queries will take more time because they do not use indexes. , when using the index, the query efficiency is significantly improved.


The above is the detailed content of Introduction to MySQL slow query operations for Mysql optimization. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template