1、指定分表關鍵字
例如:int_month int_day,每次查詢是必須要帶着分表關鍵字,根據分表關鍵字確定表明,例如user表,十月份的數據user_202110;
2、使用union all關聯多個查詢表。
例如:要查詢兩個的數據 使用union all關聯,
(select * from user_202110) UNION all (select * from user_202111);
3、union all 也支持limit, 和offset,
(select * from ohs_trade_records_202110) UNION all (select * from ohs_trade_records_202111) limit 1 offset 1;
4、最終limit 和offset在業務邏輯中限制
每一次判斷查詢結果的數量,最終在orm層判斷是否到達偏移量,確定偏移量后再一條一條查詢數據
5、這里分析一份問題,為什么使用數據庫的offset和limit;
待討論