对于大数据量的数据库表进行分页操作。
例如:
select * from table limit 9000000,100; 查了100条数据用了8.323s,这个速度难以接受
对这样的sql语句进行优化,说到查询优化,我们首先想到的肯定是使用索引。
加上id的主键索引以后:
SELECt id FROM student LIMIT 9000000,100; 总耗时4.256s
现在有两种优化方式:
即通过id作为查询条件使用子查询实现和使用join实现;
第一种:
select * from student where id >= (select id from test limit 9000000,1) limit 0,100
第二种:
SELECt * FROM test a JOIN (SELECt id FROM test LIMIT 9000000,100) b ON a.id = b.id



