Php+MySql分頁機制兩種方案的比較測試_PHP教程

來源:互聯網
上載者:User
硬體環境:PIII550,128M,15.2G
軟體環境:Win98+Apache+Php4+MySql
方案一:
1.第一次查詢時用Select count(1) from tab where condition 取得滿足條件的記錄數$rows
2.通過前頁數$page,每頁記錄數$rpp取回記錄集
select * from tab where condition limit ($page-1)*$rpp,$rpp
3.顯示返回記錄集的所有記錄。
4.頁面轉移時將$rows傳遞給以後頁面。
方案二:
1.取回滿足條件的記錄集
select * from tab where condition
2.移動指標到($page-1)*$rpp
3.顯示$rpp條記錄
==============+======+==============================================+======+======+========
記錄數 | 方案 | 次數 1 2 3 4 5 6 7 8 9 0 | 平均 | 平均 | 效率比
==============+======+==============================================+======+======+========
| |第一頁 2 , 1 , 1 , 2 , 1 , 1 , 2 , 2 , 1 , 2 | 1.3 | |
| 一 +----------------------------------------------+------+ 1.6 |
10000條記錄時 | |其它頁 2 ,2 , 2 , 3 , 1 , 1 , 2 , 2 , 2 , 2 | 1.9 | | 4.8125

http://www.bkjia.com/PHPjc/631068.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/631068.htmlTechArticle硬體環境:PIII550,128M,15.2G 軟體環境:Win98+Apache+Php4+MySql 方案一: 1.第一次查詢時用Select count(1) from tab where condition 取得滿足條件的記錄數$...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.