设为首页 加入收藏

TOP

Oracle hint之DRIVING_SITE(三)
2017-04-07 10:24:34 】 浏览:562
Tags:Oracle hint DRIVING_SITE
----------


Predicate Information (identified by operation id):


---------------------------------------------------


  2 - access("A2"."RN"="A1"."RN")


Remote SQL Information (identified by operation id):


----------------------------------------------------


  3 - SELECT "RN" FROM "TEST_LOCAL" "A2" (accessing '!' )


Note


-----


  - fully remote statement


  - dynamic sampling used for this statement


已选择27行。


已用时间:  00: 00: 00.01
 


4. 通过上面的测试,可以发现二者的执行时间是不一样的。我们再将二者分别执行100次,比较一下平均时间:


-- 将远程表拉到本地执行,耗时65.71(单位为1/100秒)


SQL> set serveroutput on


SQL> declare


  2    n_count number;


  3    n_begin_time number;


  4    n_sum_time number;


  5  begin


  6    n_sum_time := 0;


  7    for n_loop in 1..100 loop


  8      n_begin_time := dbms_utility.get_cpu_time;


  9      select count(*)


 10        into n_count


 11        from test_local l, test_remote@to_s12 r


 12        where l.rn = r.rn;


 13      n_sum_time := n_sum_time + (dbms_utility.get_cpu_time - n_begin_time);


 14    end loop;


 15    dbms_output.put_line('avg cpu_time:'||(n_sum_time/100));


 16  end;


 17  /


avg cpu_time:65.71


PL/SQL 过程已成功完成。


已用时间:  00: 01: 28.39


-- 将本地表发送到远程执行,再将结果返回到本地,耗时0.05(单位为1/100秒)


SQL> declare


  2    n_count number;


  3    n_begin_time number;


  4    n_sum_time number;


  5  begin


  6    n_sum_time := 0;


  7    for n_loop in 1..100 loop


  8      n_begin_time := dbms_utility.get_cpu_time;


  9      select/*+driving_site(r)*/ count(*)


 10        into n_count


 11        from test_local l, test_remote@to_s12 r


 12        where l.rn = r.rn;


 13      n_sum_time := n_sum_time + (dbms_utility.get_cpu_time - n_begin_time);


 14    end loop;


 15    dbms_output.put_line('avg cpu_time:'||(n_sum_time/100));


 16  end;


 17  /


avg cpu_time:.05


PL/SQL 过程已成功完成。


已用时间:  00: 00: 23.14
 


5. 结论


在分布式查询中,当一张表比较小,而且最终得到的结果集也比较小的话,使用driving_site将小表发送到大表端执行是比较快的。


首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Linux2.6内核下的MySQL5.5通用包.. 下一篇服务器时间异常造成ORA-00600 [22..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目