Business needs, optimize the period of multi-table query script.
To conclude, take the following steps.
Analysis Statement
- Analysis statements to understand the logic, is it possible to optimize the logic.
- Query query range, whether it is full-table query, and if so, to try to optimize the query by index.
- Check the number of statements, if there are duplicate sub-queries can be combined to see if there are redundant connection table.
- Try to use temporary tables can significantly improve query performance.
DROP TABLE IF EXISTS TEMP_NAME;
CREATE TEMPORARY TABLE TEMP_NAME(
COLUMN1 COLUMN_TYPE,
COLUMN2 COLUMN_TYPE
);
INSERT INTO TEMP_NAME
SELECT COLUMN1,COLUMN2 FROM DATATABLE;