我只在 done_status(done_status = INT) 上使用索引设置了我的表:
当我使用:
EXPLAIN SELECT * FROM reminder WHERE done_status=2
Run Code Online (Sandbox Code Playgroud)
我得到这个:
id select_type table type possible_keys key key_len ref rows Extra 1 简单提醒 ALL done_status NULL NULL NULL 5 使用 where
但是当我发出这个命令时:
EXPLAIN SELECT * FROM reminder WHERE done_status=1
Run Code Online (Sandbox Code Playgroud)
我得到以下返回:
id select_type table type possible_keys key key_len ref rows Extra 1 简单提醒 ref done_status done_status 4 const 2
这EXPLAIN
表明它使用 5 行,第二次使用 2 行。
我认为没有使用索引,如果我第一次理解它应该给我 3 行。我做错了什么?
SHOW INDEX FROM reminder
:
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment 提醒 1 done_status 1 done_status A 5 NULL NULL BTREE
解释扩展:
id select_type table type possible_keys key key_len ref 行过滤额外 1 简单提醒 ref done_status done_status 4 const 2 100.00
show warnings
没有表现出任何兴趣。
归档时间: |
|
查看次数: |
12655 次 |
最近记录: |