oracle数据库左连接优化,简单聊聊TiDB中sql优化的一个规则---左连接消除(Left Out Join Elimination)...

我们看看 TiDB 一段代码的实现 --- 左外连接(Left Out Join)的消除;

select 的优化一般是这样的过程:

8bf772241c2b9b3f449e2a177d1c1984.png

在逻辑执行计划的优化阶段, 会有很多关系代数的规则, 需要将逻辑执行计划(LogicalPlan)树应用到各个规则中, 尝试进行优化改写;

我们看看其中的一条优化规则: outerJoinEliminator

TiDB作为优秀的开源项目, 代码的注释也非常优秀, 里面提到了满足这些条件的 Left Outer Join 可以消除右表;

// tryToEliminateOuterJoin will eliminate outer join plan base on the following rules

// 1. outer join elimination: For example left outer join, if the parent only use the

// columns from left table and the join key of right table(the inner table) is a unique

// key of the right table. the left outer join can be eliminated.

// 2. outer join elimination with duplicate agnostic aggregate functions: For example left outer join.

// If the parent only use the columns from left table

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值