search
Homephp教程php手册比较测试PHP+MYSQL分页机制两种方案

硬件环境: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
            +----+-------------------- ------------+------+------+
            | 二 |每一页 7,7,7,8,8,8,8,8,8,8    |7.7 | 7.7 |
===========+====+============================= =====+=====+======+
            |    |第一页 25,2,3,2,21,16,9,20,9,9|1.6 |      |
            | 一 +-----------------------------------+-----+ 7.5 |
20000条记录时 |   |其它页 6,6,2,2,4,4,4,1,2,2    |3.3 |     | 6.6533
            +- --+----------------------------------+------+------+
            | 二|每一页 54,50,37,46,49,47,52,50,55,59|49.9 | 49.9 |
============+====+==================================+======+======+====
            |    |第一页 34,35,24,21,21,21,22,22,21,21| 25.2 |
            | 一 +----------------------------------+------+25.95|
30000条记录时 |   |其它页 14,27,40,39,37,33,22,30,14,11| 26.7 |    | 3.3372
            +----+----------------------------------+------+------+
            | 二 |每一页 92,90,83,78,93,83,91,79,89,88 | 86.6 | 86.6 |
============+====+==================================+======+======+===



Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)