Oracle hint Leading 的使用

Leading(): 指示Oracle在执行join(hash join, nested loop join, merge join)时的连接顺序。

当执行计划不按照最优的表连接顺序时,考虑使用Leading 改变执行计划。 使用leading 的目的是减少检索数据量, 提高查询性能。

eg:


select v.*, t.* from v_view1 join (select  /*+ leading(t1, tftc) */ * from tftc, t1 where t1.id=tftc.id) t
on v.id=t.id and v.name=t.name left join t2 on t2.name=v.name

;



LEADING Hint

Description of leading_hint.gif follows
Description of the illustration leading_hint.gif

(See "Specifying a Query Block in a Hint"tablespec::=)

The LEADING hint instructs the optimizer to use the specified set of tables as the prefix in the execution plan. This hint is more versatile than the ORDERED hint. For example:

SELECT /*+ LEADING(e j) */ *
    FROM employees e, departments d, job_history j
    WHERE e.department_id = d.department_id
      AND e.hire_date = j.start_date;

The LEADING hint is ignored if the tables specified cannot be joined first in the order specified because of dependencies in the join graph. If you specify two or more conflicting LEADING hints, then all of them are ignored. If you specify the ORDERED hint, it overrides all LEADING hints.




  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值