mysql sub-table and query problem after sub-table

I have encountered this kind of demand, and the idea is:
1. It will damage the service, only check the data within one year for him, or only store 1kw data. Create a table to store data within one year, and move the oldest data in the table to the sub-table every other month. If the demander wants to check all the data, let him choose the year to check.

2. According to the page number request (ie limit, start) from the front end, determine which year the data to be queried is in, or the data is a combination of multiple years.
If
2012 25, 2013 40, 2014 15, a total of 80 records
limit 0, 20 => fall in 2012, then just check 2012 is enough;
limit 20, 20 => 2012 last 5 + 2013 15 and so on . .
If you toss again, you can use the keyword + year as the key, and store the number of entries in the non-current year in a cache to reduce the number of calculations.
3. Finally, it is a brainless union, which should be very slow
. 4. If it is for a specific keyword Doing report statistics, one-time is optional

Decisively chose 1, because the old data basically no one cares about. .

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325686766&siteId=291194637