group by optimization
By default, mysq sorts all group bys, which is similar to specifying order by in the query. If you want to avoid the inefficiency caused by sorting, you can use order by null to disable sorting
In some cases, you can use join instead of subqueries, because using join, mysql does not need to create a temporary table in memory
If you want to use an index in a query statement containing an or, each conditional column between or must use an index