我有一个MySQL表T,列c1上有一个索引。我的连接查询如下所示。select something from T as t1 inner join T as t2 on ABS(t1.c1-t2.c1)<2;
我使用explain来查看MySQL是否使用索引。上面的查询没有使用索引。但它确实为下面的查询使用了索引。select something from
explain select * from user where id in (1,2,3)explain select name from user where id in (1,2,3) explain select id from user where id in (1,2,3)
Mysql显示类型是索引。
some_other_column不是任何索引的一部分。primary_index_column是主键列;secondary_index_column有一个b树索引,基数为200 (根据MySQL)。以下是explain的结果:
mysql> explain select some_other_column from `table` order by primary_index_column limit要为第二个查询选择特定的执行计划?我不明白为什么它可以将索引用于第一个查