有三列,第一列是id,第二列是name,第三列是tip,其中第一列是主键。里面有5000条数据,输入以下命令:
mysql> explain select * from test_isam\G;
*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: test_isam
         type: ALL
possible_keys: NULL
          key: NULL
      key_len: NULL
          ref: NULL
         rows: 5000
        Extra:
1 row in set (0.00 sec)
其中显示select操作时没有使用索引。下面我强制使用索引:
mysql> explain select * from test_isam force index(PRIMARY) \G;
*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: test_isam
         type: ALL
possible_keys: NULL
          key: NULL
      key_len: NULL
          ref: NULL
         rows: 5000
        Extra:
1 row in set (0.00 sec)
怎么还是显示没有索引?