Speed paging method
1. Scope of application
The average speed paging method is mainly applicable to ASP+ACCESS applications with fixed sorting methods such as article systems and news systems.
2. Feature description
Many friends who have used some article systems or news systems know that when general article systems or news systems are classified and paging, they usually read the sorted data in the database that meets the conditions, and then point to a certain piece of data according to the requested page number through positioning operations, and start reading several pieces of data after the data as a page. This pagination method has a simple principle, but the problem is that every time you need to read out the sorting data in the database that meets the conditions. If there are two thousand pieces of data, this is fine, but what if there are twenty thousand pieces of data? It shows that this will consume a lot of memory and waste a lot of server resources. Of course, if you have the conditions, you can use SQL database, which will be much easier. You can solve all the problems with a little stored procedure. However, many friends may still use ACCESS database, so there is nothing we can do about it. Of course, there are also some programs that generate HTML for pagination, just like many download sites. Have you ever thought about what problems will occur in this way? If I add one record at a time in the background, then I have to regenerate all the pages in this category HTML once. This is for sure. Think about it, is this very effective?
The average-speed paging method is designed to solve the problem of pagination of a large amount of data in the ACCESS database. It combines the advantages of HTML paging and traditional ADO paging. First, the speed is fast and takes up less resources. Whether you are on the first page or the first hundred page, the program speed is the same. And when adding data, you don't have to regenerate all pages. I'll introduce the principle below
3. Paging principle
There is an article table and a class table in the database. We do not consider whether it is an infinite-level classification or a two-level classification. This has nothing to do with us.
[article]idintIDENTITY(1,1)NOTNULL,classidintdefault0,titlevarchar(100),addtimedatetime
[class]idintIDENTITY(1,1)NOTNULL,classnamevarchar(20)
1. Generate paging
If there is a row of data in the class table with id of 1 and classname is "ASP classification", we first take out all the data with classid=1 in all articles, and then arrange it in ascending order of addtime. This is the same as ordinary ADO facets, but we need to do some processing below.
We dynamically generate a table in the database, named [page_1], and 1 is the corresponding classname automatically numbered with the ID of "ASP Classification".
[page_1]pagenumint,pagesttext
We first generate a str for every 20 pieces of data. Each str is actually a list of the 20 databases when displayed, and then number this str. If it is 0-19 records, then XXX is 001. If it is 20-39, XXX is 002, and so on. Add str and its number to page_1. We assume the largest one here is 84