Home  >  Article  >  Database  >  Example tutorial of physical paging and logical paging

Example tutorial of physical paging and logical paging

零下一度
零下一度Original
2017-07-18 18:09:431299browse

Take you to understand what physical paging and logical paging are?

1. Physical paging

Physical paging relies on a certain physical entity. This physical entity is the database. For example, the MySQL database provides the limit keyword. Programmers only need to write SQL statements with the limit keyword, and the database returns paging results.

2. Logical paging

Logical paging relies on code written by programmers. The database returns not the paging results, but all the data, and then programmers obtain the paging data through code. A common operation is to query all the data from the database at once and store it in the List collection, because ListThe collection is sorted, and then the specified range of data is obtained according to the index.

Second comparison

1. Database burden

Physical paging accesses the database every time. Logical paging only accesses the database once, while physical paging places a heavy burden on the database.

2. Server burden

Logical paging reads data into the memory at one time, occupying a large content space, and physical paging each time Only a part of the data is read at a time, occupying small memory space.

3. Real-time performance

Logical paging reads data into memory at one time. If the data changes, it cannot be reflected in the operation in real time. Poor real-time performance. Physical paging accesses the database every time data is needed, and can obtain the latest status of the database, with strong real-time performance.

4. Applicable occasions

Logical paging is mainly used in situations where the amount of data is not large and the data is stable. Physical paging is mainly used when the amount of data is small. Larger and frequently updated occasions.

The above is the detailed content of Example tutorial of physical paging and logical paging. For more information, please follow other related articles on the PHP Chinese website!

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