????????????????????

mysql> EXPLAIN SELECT * FROM test.`friends` WHERE fuid=’364′ and fname=’test5′;
+—-+————-+———+——+—————+————+———+————-+——+————-+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+—-+————-+———+——+—————+————+———+————-+——+————-+
| 1 | SIMPLE | friends | ref | fuid_fname | fuid_fname | 112 | const??const | 2 | Using where
+—-+————-+———+——+—————+————+———+————-+——+————-+

????Sql????????SELECT * FROM test.`friends` WHEREfname=’test5′ and fuid=’364′;???????????????Ч?????????ELECT * FROM test.`friends` WHERE fuid=’364′ and fname=’test5′????????????;

mysql> EXPLAIN SELECT * FROM test.`friends` WHERE fname=’test5′ and fuid=’364′;
+—-+————-+———+——+—————+————+———+————-+——+————-+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+—-+————-+———+——+—————+————+———+————-+——+————-+
| 1 | SIMPLE | friends | ref | fuid_fname | fuid_fname | 112 | const??const | 2 | Using where
+—-+————-+———+——+—————+————+———+————-+——+————-+

????6???????????????????????????????????????????????????????????????Ч??????????????????????ε????????????

????????????????????explain

????????????????????о????????Щ??????????????????????????????????Ч???????sql??????????????Щsql????е?????????Э?????????????????????????????explain??

????explain?????mysql????????????????select????????????????????????????????д??????????????

??????÷???????select????????explain???????

mysql> explain select * from test.index_test where time1=’20130517100552′;
+—-+————-+————+——+—————+——-+———+——-+——+————-+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+—-+————-+————+——+—————+——-+———+——-+——+————-+
| 1 | SIMPLE | index_test | ref | time1 | time1 | 253 | const | 1 | Using where |
+—-+————-+————+——+—————+——-+———+——-+——+————-+

????EXPLAIN?е?????

????id??SELECT??????????SELECT???????к?????????????????????id????1??????Mysql????id???С????????query????id?????????£???????????С?

????table?????????е?????????????????

????type????????????У?????????????????????

????Explain??type???????????????????????????????????????????????

????system>const>eq_ref> ref > range > index > ALL

????possible_keys??????????????????е???????????????????п??????????????????????WHERE???????????????????

????key???????????????????NULL?????????????????????????£?MYSQL???????????????????????????£???????SELECT????????USE INDEX??indexname???????????????????????IGNORE INDEX??indexname???????MYSQL??????????

????key_len????????????????????????????????£??????????á?

????ref???????????????б?????????????????????????????

????rows??MYSQL?????????????????????????????????

????Extra??????MYSQL??ν????????????????

????Extra?з????????

????Distinct?????MYSQL????????????????????У???????????

????Not exists??MYSQL?????LEFT JOIN???????????????LEFT JOIN??????У???????????

????Range checked for each Record??index map:#??:????????????????????????????????????????????MYSQL???????????????????????????з????С????????????????????????

????Using filesort????????????????????п????????????MYSQL??????ж???????????????ζ?????????????????????????????洢?????????????????????е?????????????????

????Using index????????????????????????е????????ж???????ж????????????????????????????ж????????????????????

????Using temporary ????????????????????????????MYSQL??????????????????洢??????????????????????м?????ORDER BY?????????GROUP BY??

????Using where???????WHERE???????????Щ?н?????????????????????????????????????е?????У?????????????ALL??index?????????????????????????????????????