select id,title from collect limit 0,10;
select id,title from collect limit 1000,10;
select id,title from collect limit 90000,10;
select id from collect order by id limit 90000,10; -走主键索引
select id,title from collect where id>=(select id from collect order by id limit 90000,1) limit 10; -走主键索引
带查询条件
select id from collect where vtype=1 order by id limit 90000,10;
create idx_search(vtype,id)
select id ,title from collect where vtype=1 limit 90000,10;--慢
如果对于有where 条件,又想走索引用limit的,必须设计一个索引,将where 放第一位,limit用到的主键放第2位,而且只能select 主键
最终办法 用IN 查询主键,会走索引
select * from collect where id in (9000,12,50,7000);