由于优化器无法获取remote的表的统计数据, 因此可以考虑改为如下的语句, 测试一下, 看结果是否完全正确, 并测试一下性能
merge into vf
using (select rid,
c1,
c2,
c3
c4
from (select /*+ DRIVING_SITE(tf) */
vf.rowid rid,
tf.sid,
max(tf.sid) over(partition by tf.c2) max_sid tf.c1,
tf.c2,
tf.c3 tf.c4
from vf,
@ln_exp tf
where vf.c2 = tn.c2
and vf.c1 = tn.c1
and tf.c1 = 'XXXXXXX')
where sid = max_sid) tn
on(vf.rowid = tn.rid)
when matched then
update set vf.c3 = tn.c3, vf.c4 = tn.c4
when not matched then
insert (vf.c1, vf.c2, vf.c3, vf.c4) values (tn.c1, tn.c2, tn.c3, tn.c4);