Home > php教程 > php手册 > Php+MySql分页机制两种方案的比较测试

Php+MySql分页机制两种方案的比较测试

WBOY
Release: 2016-06-13 10:05:57
Original
1603 people have browsed it

硬件环境: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

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template