1. SELECT clause
In sufficient cases, you can select only columns with indexes that are very fast
If unnecessary, selecting only the columns you want to view will increase your speed.
2. FROM clause
When you use join, you can directly join the table, and if the join subquery, the temporary table generated by the subquery is not indexed, so it can cause slow speed, and the direct join table can increase the speed.
Use different joins depending on the situation to increase the speed of queries and statistics
3. WHERE clause
Conditions in the WHERE clause:
Add an index of type btree if you need to sort, whether unique or not
If it is a unique value and does not require sorting, add a unique hash index
If it is not a unique value and does not require sorting, and if there are not many duplicate values, you can add a hash index
4. ORDER BY clause
By conditions it is best to add Btree index
Database Query Tuning