SQlserver高效分页,还在使用row_number(),top之类的?

row_number() ,还是top 这些分页的方法比较老了,效率不是很高效的,

Sqlserve2012就有了,效率对比比较明显,尤其是数据比较大的情况下(我们可以观看查询执行计划)

Offset 0 Rows Fetch Next 20 Rows only(需要先排序)

这里只举一个接单的sql,只起到抛砖引玉的作用:

select id,name from Student order by id desc  Offset 0 Rows Fetch Next 20 Rows only

 

猜你喜欢

转载自www.cnblogs.com/Fengge518/p/11448650.html