How to improve the efficiency of mysql database query statements? There are hundreds of millions of records in the table, but it is still slow to specify the index.
First, analyze why it is slow: 1. 6 subqueries, and each subquery needs to establish an intermediate table; 2. Each subquery is doing group by, repeating; 3 when the index is not used and all columns need to be scanned; Optimization: Case When the logic is merged, six subqueries are merged into 1 query, and 1 group by, and join,