MySQL011–如何处理MySQL的慢查询(MySQL 011 — how to handle slow queries of MySQL)






1. Start the slow query log to locate the SQL statement that has a problem.

2. Analyze the SQL statement to see if additional data is loaded. It may be that redundant rows are queried and discarded. It may be that many unnecessary columns in the results are loaded. Analyze and rewrite the data.

3. Analyze the execution plan of the statement, and then obtain its use of the index. Then modify the statement or modify the index, and try to get that the statement can hit the index as much as possible.

4. If it is impossible to optimize the statement, you can consider whether the amount of data in the table is too large. If so, you can divide the table horizontally or vertically.