You may need some more specific cases of SQL optimization as the current ones are not detailed enough. However, the general approach to MySQL optimization can refer to the following steps:
- Design a reasonable table structure based on the business requirements and prepare appropriate indexes for the query conditions.
- Observe the slow log or other means to detect which SQL statements may affect performance. Continuous monitoring is required.
- After identifying the slow - running SQL statements from the slow log, analyze whether they are reasonable, whether indexes are utilized, and whether the indexes should be modified.
- Take SQL optimization courses to at least know which types of SQL statements may not be able to utilize indexes even if they exist.
- Continuous monitoring is of great importance.
Of course, this is only the optimization for SQL, indexes, and table structures. If you want to further optimize, it needs to be carried out at the operating system and hardware levels.