如题。
#索引
alter table test add index `idx`(`discount_amount`,`limit_amount`);
使用了覆盖索引,但还会出现 using where
mysql> explain select discount_amount from test where discount_amount=10 and limit_amount>10;
+----+-------------+-------+-------+------+---------+--------+--------------------------+
| id | select_type | table | type | key | key_len | rows | Extra |
+----+-------------+-------+-------+------+---------+--------+--------------------------+
| 1 | SIMPLE | test | range | idx | 4 | 660750 | Using where; Using index |
+----+-------------+-------+-------+------+---------+--------+--------------------------+
现在有点懵了,使用到 using where 的查询执行流程是怎样的?
1
gclover 2016-06-29 13:53:28 +08:00
优化器会在索引存在的情况下,通过符合 RANGE 范围的条数和总数的比例来选择是使用索引还是进行全表遍历
https://segmentfault.com/q/1010000004197413 |