禁止使用索引:ignore index---------------------強制使用索引: force indexmysql
mysql> explain select * from userinfo where username='test1'\G *************************** 1. row *************************** id: 1 select_type: SIMPLE table: userinfo type: ref possible_keys: username key: username key_len: 768 ref: const rows: 1 Extra: Using where 1 row in set (0.00 sec) mysql> explain select * from userinfo ignore index(username) where username='tes t1'\G *************************** 1. row *************************** id: 1 select_type: SIMPLE table: userinfo type: ALL possible_keys: NULL key: NULL key_len: NULL ref: NULL rows: 4 Extra: Using where 1 row in set (0.00 sec)