分页

引用:http://bbs.bwsyq.com/%E8%B7%9F%E5%A4%A7%E5%AE%B6%E5%88%86%E4%BA%AB%E7%82%B9%E4%BF%BA%E5%88%9A%E8%8A%B1%E4%BA%86-30%E5%88%86%E9%92%9F%E6%97%B6%E9%97%B4%E7%A0%94%E7%A9%B6%E5%87%BA%E6%9D%A5%E7%9A%84%E9%AB%98%E4%BB%B7%E5%80%BC%E7%9A%84%E6%8A%80%E6%9C%AF_t75.aspx?siteId=0&forumId=17

 

这是普通的分页技术(各大技术论坛上所谓的“高手”都这么写的),每页显示 30条数据 ,到最后执行需要 30秒,CPU占用达 50%

 

select [F0001],[F0002],[F0004],[F0005],[F0006],[F0007],[F0008],[F0009],[F0010],[F0011],[F0012],[F0015],[F0016],[F0017] 
from (
SELECT  
[F0001],[F0002],[F0004],[F0005],[F0006],[F0007],[F0008],[F0009],[F0010],[F0011],[F0012],[F0015],[F0016],[F0017],
ROW_NUMBER() OVER (order by [F0001]) as RowNumber FROM [T0502_T0501_View] ) as t where  
t.RowNumber between 6666600 and 6666630 order by [F0001]

 

 

分页每页显示 30条数据 ,到最后需要CPU占用不到 5% ,用时不到0.3秒

select getdate()
select t.*
from (
SELECT  
[F0001],
ROW_NUMBER() OVER (order by [F0001]) as RowNumber FROM [T0502_T0501_View] ) as t 
left join [T0502_T0501_View] t1 on t.f0001=t1.f0001
where  
t.RowNumber between 666600 and 666630 order by [F0001]

 

一点小小的分享,希望对大家有帮助!

 

你可能感兴趣的:(分页)