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
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
Don't put too much trust in the "rows" Statement of EXPLAIN. As in the mysql docs: "Estimate of rows to be examined" (http://dev.mysql.com/doc/refman/5.1/en/explain-output.html).
Perhaps updating your index statistics will give you a better estimate (OPTIMIZE TABLE, http://dev.mysql.com/doc/refman/5.0/en/optimize-table.html)