oracle 语句优化。有关联条件,但表在连接时还是merge join,建成临时表或变换表位置变成hash join 是什么原因
在oracle中代码如下
select t2.home_county, count(distinct t1.user_id)
from user_t2 t2
inner join vpn_t1 t1 on t1.sum_month = 201212
and t1.inure_date <=
to_date(20121231, 'yyyymmdd')
and t1.expire_date >=
to_date(20121231, 'yyyymm')
and t1.user_id = t2.user_id
inner join team_t3 t3 on t3.change_inure_date <=
to_date(20121231, 'yyyymmdd')
and t3.change_expire_date >
to_date(20121231, 'yyyymmdd')
and t3.inure_time <=
to_date(20121231, 'yyyymmdd') + 1
and t3.expire_time >=
to_date(20121231, 'yyyymmdd')
and t3.team_sub_type = 31
and t3.team_id = t1.vpn