分页查询可以有效降低服务器使用率,减小IO读写压力。对比多个分页查询语句总结如下,效率最高:
SELECT * FROM(SELECT*, ROW_NUMBER() OVER(ORDER BY ID desc) RN,COUNT(*) OVER() AS allcount FROM t_table where xxx=" + xxx+ ") T WHERE RN BETWEEN " + (pageNum - 1) * pageCount + " AND " + pageNum * pageCount