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)
2. Simple test:
1. Add a table with a single record of about 4 million
3. Structure: no_index character is not indexed
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.
5. Test after no_index indexing:
6. Use this statement to view the structure in the table
7. Testing after adding the index, it was found that after using the index, the query efficiency is significantly accelerated
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!