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层判断是否到达偏移量,确定偏移量后再一条一条查询数据  

mysql分库分表,多张表如何查询

 

 

5、这里分析一份问题,为什么使用数据库的offset和limit;

  待讨论

相关文章:

  • 2021-12-22
  • 2021-12-19
  • 2022-12-23
  • 2021-07-12
  • 2021-12-10
猜你喜欢
  • 2021-09-24
  • 2021-08-12
  • 2021-10-19
  • 2022-12-23
  • 2021-07-30
相关资源
相似解决方案