21.3.6 范围条件右侧的列无法使用索引
使用联合索引查询数据时,如果按照联合索引中字段的某个范围查询数据,则此字段后面的列无法使用索引,会进行全表扫描。
mysql> EXPLAIN SELECT * FROM t_goods WHERE t_category_id > 1 AND t_name = '卫衣' \G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: t_goods
partitions: NULL
type: ALL
possible_keys: category_name_index
key: NULL
key_len: NULL
ref: NULL
rows: 14
filtered: 7.14
Extra: Using where
1 row in set, 1 warning (0.01 sec)