????1?? ??????
??????м????????????????sql???????????????????????mysql????м???????oracle??????????????????SQL?????????????
???????????????mysql??м????????????????
????2?? ??м??????????
????2.1 ??м?????????????explain select …………….
??????????????????????select????explain????
????2.2 ??м?????
????Id?????????????????????????select?????????????
????????????С??У?
??????id??????????????????????£?
????Select_type:???????????select???????????OR????????????????
????SIMPLE??????в?????????????UNION
????PRIMARY?????????????κθ?????????????????????PRIMARY
????SUBQUERY????SELECT??WHERE?б??а???????????????????????SUBQUERY
????DERIVED????FROM?б??а???????????????DERIVED????????
??????????SELECT??????UNION?????????UNION??
??????UNION??????FROM?????????У????SELECT??????????DERIVED
??????UNION?????????SELECT????????UNION RESULT
????Type?????MySQL?????????????е????????“????????”???????????????
????ALL??Full Table Scan?? MySQL???????????裻
????index??Full Index Scan??index??ALL?????index?????????????????
????range??range Index Scan????????????迪???????????????????У???????between??<??>???????
????ref????????????裬???????????????????????С?????????÷???????????????????е?????
????eq_ref??????????裬?????????????????????????????????????????????????????
????const??system????MySQL??????????????????????????????????????Щ?????????罫????????where?б??У?MySQL????ò?????????????
????NULL??MySQL??????????з????????????????÷?????????
????possible_keys?????MySQL?????????????????????У?????漰????????????????????????????????г???????????????????
????key?????MySQL?????????????????????????????????????NULL????????????????????????????????????????key?б???
????key_len??????????????????????????????м????????????????????
????ref?????????????????????????????Щ?л????????????????????????
????rows?????MySQL????????????????????????????????????????????????????????
????Extra??????????????????????????????????????????
????Using where?????MySQL????????洢???????????????“?????”??Post-filter??????????δ???????????Using where?????????????????MySQL????where?????????????
????Using temporary?????MySQL??????????????洢?????????????????????????
????Using filesort??MySQL???????????????????????????“???????”??
????2.3 mysql??м???????
????EXPLAIN????????????????????洢?????????????????庯??????????????
????EXPLAIN?????????Cache
????EXPLAIN???????MySQL????в????????????????
????????????????????????????
????EXPALIN??????SELECT?????????????????д?SELECT?????м??