Mysql之禁止使用索引

禁止使用索引:ignore index---------------------强制使用索引: force index

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)

 

posted @ 2013-09-05 09:13  爱我所艾  阅读(1510)  评论(0编辑  收藏  举报