- Background: the project uses mybatis as the database framework, and the database table structure has a status field to identify whether the data is expired or not. The expired data is no longer queried, but is still kept in the database. The query data needs communication transmission, the amount of data can not be too large, so consider using paging query. On the other hand, frequent database query will reduce the efficiency, so consider using redis as the secondary cache of mybatis.
- Problem Description: during paging query, the data stored in the database may be updated, inserted or expired at any time by the user, which leads to:(1)Whether using traditional mybatis logical paging or physical paging, offset can not be used as the starting point of this paging query directly, because new data may be inserted at any time or some data may be invalid and expired. This query may include some duplicate data in the last paging data.(2)If Id is used as the starting point of pagination (ID > XX limit XX), some problems can be solved, but another operation of the project is "sort by amount", so that the data becomes out of order and can no longer be paginated by ID.So, how to design solutions to solve this problem.I would appreciate it if you could help me!
↧
Using mybatis paging query, database data can be inserted or updated at any time. At this time, paging query may find duplicate data. How to solve?
↧