Comparison between the two paging schemes of Php + MySql _ MySQL

Source: Internet
Author: User
Hardware environment: PIII550, 128 M, 15.2G software environment: Win98 + Apache + Php4 + MySql Solution 1: 1. use Selectcount (1) fromtabwherecondition for the first query to obtain the number of records meeting the condition $ rows2. pass the previous page number $ page, number of records per page $ rpp retrieve record set select * fromtabwhereconditionlimit ($ page-1) * hardware environment: PIII550, 128 M, 15.2G
Software Environment: Win98 + Apache + Php4 + MySql

Solution 1:
1. use Select count (1) from tab where condition for the first query to obtain the number of records meeting the condition $ rows
2. use the first page $ page to retrieve the record set per page $ rpp
Select * from tab where condition limit ($ page-1) * $ rpp, $ rpp
3. display all records of the returned record set.
4. transfer $ rows to a later page during page transfer.

Solution 2:
1. retrieve records that meet the conditions
Select * from tab where condition
2. move the pointer to ($ page-1) * $ rpp
3. Display $ rpp records

======================= ============================================= ==+ =========
Number of records | scheme | times 1 2 3 4 5 6 7 8 9 0 | average | Efficiency ratio
======================= ============================================= ==+ =========
| Page 1 2, 1, 1, 2, 1, 1, 2, 2, 1, 2 | 1.3 |
| 1 + ---------------------------------------------- + ------ + 1.6 |
10000 records | other pages 2, 2, 2, 3, 1, 1, 2, 2, 2 | 1.9 | 4.8125
+ ------ + ---------------------------------------------- + ------ +
| 2 | 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8 | 7.7 |
======================= ============================================= ==+ =========
| Page 1 25, 2, 3, 2, 21, 16, 9, 20, 9, 9 | 1.6 |
| 1 + ---------------------------------------------- + ------ + 7.5 |
20000 records | other pages 6, 6, 2, 2, 4, 4, 4, 1, 2, 2 | 3.3 | 6.6533
+ ------ + ---------------------------------------------- + ------ +
| 2 | 54, 50, 37, 46, 49, 47, 52, 50, 55, 59 | 49.9 |
======================= ============================================= ==+ =========
| Page 1 34, 35, 24, 21, 21, 21, 22, 22, 21, 21 | 25.2 |
| 1 + ---------------------------------------------- + ------ + 25.95 |
30000 records | other pages 14, 27, 40, 39, 37, 33, 22, 30, 14, 11 | 26.7 | 3.3372
+ ------ + ---------------------------------------------- + ------ +
| 2 | 92, 90, 83, 78, 93, 83, 91, 79, 89, 88 | 86.6 |
======================= ============================================= ==+ =========

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.