Code Optimization Summary

Recently a function query was slow for a minute, so I managed to optimize it and finally optimized it to within 8 seconds.

Summary: The optimized code is mainly optimized from these parts:

1.sql

2. Code

3. Data

4. Index

 

<!--[if !supportLists]--> 1.      <!--[endif]--> Check the execution plan through sql explain , which parts do not use indexes and which parts of sql execute slowly, and locate them carefully

<!--[if !supportLists]--> 2.      <!--[endif]--> Optimize sql to minimize the use of subqueries and use join

<!--[if !supportLists]--> 3.      <!--[endif]-->Check whether the speed is faster by adding an index

<!--[if !supportLists]--> 4.      <!--[endif]--> If it doesn't work, see if other code is dragging down the query

<!--[if !supportLists]--> 5.      <!--[endif]--> If there is no above problem, check whether there is garbage data generated in the data, resulting in data expansion

<!--[if !supportLists]--> 6.      <!--[endif]--> Check the code again to see what caused the garbage data

 

<!--[if !supportLists]--> 7.      <!--[endif]--> Mysql left join does not go to the index, pay attention to this problem

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326970952&siteId=291194637