select /*+ use_nl(b a) leading(b) index(a ix_pid)*/ a.cserviceid, a.contentid
from t1 a,
(select column_value contentid
from table(cast(vntb_l_contentid as arr_varchar100))) b
where a.contentid = b.contentid
and a.productid = str_productid; select /*+leading(a) use_hash(a b)*/
a.brandid,
a.brandname,
a.brand_en,
a.detail,
a.createtime brand_createtime,
b.modelid,
b.modelname,
b.description,
c.agentid, --b.agentid,
b.msrx,
b.msry,
b.ssrx,
b.ssry,
b.chord,
b.createtime model_createtime
from a,
b,
c
where a.brandid = b.brandid
and b.modelid = c.modelid(+)
order by brandid;
我的问题:
1.use_hash和leading的使用场合?
2.上面两种情况下一般是b表作为驱动表吗?
将指定的表作为连接次序中的首表. 将B表作为首表
/*+USE_NL(TABLE)*/
将指定表与嵌套的连接的行源进行连接,并把指定表作为内部表.,你的是把B,A表作为驱动表
晕,怎么会对cost优化器没用呢?正是因为基于cost的优化器需要计算评估每种连接方式的代价,然后选择最优的那种,所以用指定hint的方式可以省略这个评估时间,大大提高执行速度,而且可以让执行的效率更稳定,不会时常变更执行计划。当然,一定要用正确的hint,否则就起反作用了。