First of all, because of the recent project used cache Redis and there are more query paging, so use a pageentity class, so that entity classes need to use the time to inherit the page.
Use this class.
Your sort is more sour.
And then, how.
1, the design of the table, you must have this three fields Create_time, status, Status_time
2, according to these three fields to filter the data scene is too much
3, if these three fields can not meet your query data needs, so good to do, extends this pageentity
4, so, you do not need to write so many strange query of the paging SQL.
For too many queries we can fix this: cache the results of the query.
Cached key, with Getattrval4forrediskey.getattrval4forrediskey,
This is hset, and the structure inside is
Total:xxx page1 List1 page2 List2 .....
The cache has a valid time of 30 seconds.
The advantages of doing so is self-evident that many pages, users silly not to pull a few, will not enter so many conditions, is the condition, we do not need to query many times, is not ....
Here's how the Redis is drafted:
Combined with the first two, one way we design the table can be easy to page and conditionally query, and very good query results are also cached, very good to reduce the number of repeated queries