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.
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.
Physical paging accesses the database every time. Logical paging only accesses the database once, while physical paging places a heavy burden on the database.
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.
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.
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!