Explain MySQL explain execution plan maths, difference between two plans

前端 未结 2 1836
-上瘾入骨i
-上瘾入骨i 2021-02-14 11:49

I\'ve got a basic MySQL performance question related to explain. I have two queries that return the same result and I am trying to understand how to make sense of the EXPL

2条回答
  •  失恋的感觉
    2021-02-14 12:04

    In fact when you see you should not to multiply, but sum this numbers. In you case compare (49520 x 413 x 4) and (50000 + 49520).

    Gereral rule is simple: summarize all segments (DERIVED, PRIMARY) and multiply rows within each segment.

    id select_type  ... rows
    1  PRIMARY           1
    1  PRIMARY           2
    2  DERIVED           3
    2  DERIVED           4
    3  DERIVED           5
    3  DERIVED           6
    

    Complexity is: 1*2 + 3*4 + 5*6

提交回复
热议问题