sharding-jdbc绑定表的解析
2021-11-19 本文已影响0人
Britney_z
例如我们执行这个sql: SELECT o.* FROM t_order o JOIN t_order_item i ON o.order_id=i.order_id and o.user_id IN(10,16),
我们看看设置绑定表规则:sharding.jdbc.config.sharding.binding-tables[0]=t_order,t_order_item
看看是如何改写sql的?
下面路由到两个TableUnits,然后遍历两个TableUnits

我们看下SQLRewriteEngine 的getTableTokens方法,查找表绑定规则

我们找t_order_10绑定的对应的t_order_item_10


如果不设置绑定表规则,tableunit

笛卡尔路由sql
