大数据量下的分页解决方法

查询结果集如果记录数比较多时,服务器内存和浏览器内存都可能溢出,另外,数据量太大客户端的性能会降低,滚动条较小,操作也不方便,需要数据库分页查询。

SQL Server分页:

SELECT TOP #{pageSize} * FROM STUDENTS WHERE ID NOT IN

(

SELECT TOP #{pageSize} * (#{pageNumber}-1) ID

FROM STUDENTS

ORDER BY ID

) ORDER BY ID

My SQL分页:

SELECT *

FROM STUDENTS

ORDER BY ID

LIMIT #{pageSize}*(#{pageNumber}-1),#{pageSize}

 

Oracle分页:

SELECT * FROM

(

  SELECT T1.*

  FROM

  (

    SELECT T.*, ROWNUM RN FROM TR_ORDER T ORDER BY T.ORDER_ID DESC

  ) T1

  WHERE

  T1.RN<=#{pageSize} * #{pageNumber}

) T

WHERE T.RN>#{pageSize}*(#{pageNumber}-1)

 

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