证实下确实是150万+数据哈
Original SQL
Original SQL execution plan
The original SQL execution time is about 5 seconds
Raw SQL Analysis
Source of ideas
Looking at SQL as a whole, it seems that there is nothing to optimize. Then we could be very wrong.
Some people may say why table B is abnormal behind table A, because this is an inner join query, not a left and right join query. The order of A and B tables can be exchanged (the actual measurement has no effect).
First, we can see that the extra of the execution plan is User where;Using temporary;Using filesort
type ALL全表扫描
, indicating that there is a problem with the SQL and needs to be optimized.