大数据量SqlServer效率分页

SET @rowsPerPage = 10 
   

SET @pageNum = 3 
     
    With SQLPaging 
    As 
    ( 
    Select Top(@rowsPerPage * @pageNum) ROW_NUMBER() OVER (ORDER BY id) as resultNum, id 
    FROM myTable 
    ) 
    select * from SQLPaging where resultNum > ((@pageNum - 1) * @rowsPerPage)  

分页不要用where not in 有些情况下效率低下

转成通用的分页存储过程

发表评论

邮箱地址不会被公开。 必填项已用*标注