本人只是测试人员,这次只提供一个优化方案,至于原理,不要问我,我也不懂,如果有更好的方法,欢迎提供
数据量1000W
原sql,用时 30.253632
select id,id_1,id_2 from (select row_number()over(order by id)as z, id,id_1,id_2 from 表名)where z>9900000 and z<= 10000000
优化后sql,用时 5.287164
select id,id_1,id_2 from 表名(select min(id) as a,max(id) as b from(select row_number()over(order by id)as z, id from 表名)t where z>9900000 and z<= 10000000)y
where t.id>=y.a and t.id<= y.b
id有索引
id_1没有索引
id_2没有索引