none
【ASP.NET】大量数据提取分页问题 RRS feed

  • 问题

  • 有一个问题我一直以来不明白,就是在数据库非常大的情况下,分页是如何实现的?比如数据表中有10000万条数据查询出来分页显示是如何实现的?

    是每次分页取数据,还是一次取出放到数据集里进行分页?请有经验的朋友指点一下,谢谢!

    2010年9月1日 3:40

答案

  • 比如数据库是SQL Server 2005以上版本,每页5行的话

    SELECT *FROM (SELECT ROW_NUMBER() OVER(ORDER BY person) AS rownum, person, income FROM Salaries) AS Salaries1 WHERE rownum >= 5 AND rownum <= 9ORDER BY income

    就是取的第二页数据

     



    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    • 已标记为答案 jinwb1982 2010年9月10日 7:38
    2010年9月8日 3:01
    版主

全部回复

  • 都是在数据库内分页,数据量大的话把数据从数据库服务器传输到web服务器再分页不太现实

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    2010年9月1日 17:44
    版主
  • 都是在数据库内分页,数据量大的话把数据从数据库服务器传输到web服务器再分页不太现实

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    请问版主,所谓的数据库分页是什么意思?是不是说不能一次性全部取出,用多少数据就先从数据库中取多少呢?(抱歉可能我语言没有组织好,但就是想说明这个问题,不知道你能否听明白)
    2010年9月8日 1:26
  • 比如数据库是SQL Server 2005以上版本,每页5行的话

    SELECT *FROM (SELECT ROW_NUMBER() OVER(ORDER BY person) AS rownum, person, income FROM Salaries) AS Salaries1 WHERE rownum >= 5 AND rownum <= 9ORDER BY income

    就是取的第二页数据

     



    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    • 已标记为答案 jinwb1982 2010年9月10日 7:38
    2010年9月8日 3:01
    版主
  • 都是在数据库内分页,数据量大的话把数据从数据库服务器传输到web服务器再分页不太现实

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    请问版主,所谓的数据库分页是什么意思?是不是说不能一次性全部取出,用多少数据就先从数据库中取多少呢?(抱歉可能我语言没有组织好,但就是想说明这个问题,不知道你能否听明白)
    数据库内存分页,取出的数据只是你过滤出来的那部分,等于你后面说的"用多少取多少"
    2010年9月10日 8:34