ITPub博客

首页 > Linux操作系统 > Linux操作系统 > merge into三种表连接方式的性能比较(一)

merge into三种表连接方式的性能比较(一)

原创 Linux操作系统 作者:wisdomone1 时间:2012-12-10 13:43:40 0 删除 编辑
SQL> show user
USER 为 "SYS"
SQL> alter system flush buffer_cache;
系统已更改。
SQL> alter system flush shared_pool;
系统已更改。
SQL> set time on
21:51:31 SQL> set timing on
21:51:34 SQL> merge /*+ use_merge(t tmp) */ into t_big t using t_big_tmp tmp on
(t.big_id=tmp.big_id) when not matched then insert (t.big_id,big_name) values(tm
p.big_id,tmp.big_name);
1000000 行已合并。
已用时间:  00: 00: 02.43
21:52:08 SQL> rollback;
回退已完成。
已用时间:  00: 00: 00.20
21:52:14 SQL> alter system flush buffer_cache;
系统已更改。
已用时间:  00: 00: 06.25
21:52:30 SQL> alter system flush shared_pool;
系统已更改。
已用时间:  00: 00: 00.03
21:52:37 SQL> merge /*+ use_hash(t tmp) */ into t_big t using t_big_tmp tmp on (
t.big_id=tmp.big_id) when not matched then insert (t.big_id,big_name) values(tmp
.big_id,tmp.big_name);
1000000 行已合并。
已用时间:  00: 00: 04.16
21:52:55 SQL> rollback;
回退已完成。
已用时间:  00: 00: 00.17
21:53:14 SQL> alter system flush buffer_cache;
系统已更改。
已用时间:  00: 00: 08.48
21:53:33 SQL> alter system flush shared_pool;
系统已更改。
已用时间:  00: 00: 00.01
21:53:37 SQL> merge /*+ use_nl(t tmp) */ into t_big t using t_big_tmp tmp on (t.
big_id=tmp.big_id) when not matched then insert (t.big_id,big_name) values(tmp.b
ig_id,tmp.big_name);
^C
C:\Users\123>
C:\Users\123>
C:\Users\123>
C:\Users\123>

小结:真正表100w记录,临时表无记录,二表相同表结构
   二表皆无索引,use_merge>use_hash>use_nl

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/9240380/viewspace-750844/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 测试itpub
请登录后发表评论 登录
全部评论
提供针对oracle初学者及进阶的数据库培训,欢迎大家咨询: 微信: wisdomone 微信公众号: lovedb 工作经历: 中国普天 北京科蓝 北京云和恩墨 北京神州新桥

注册时间:2008-04-04

  • 博文量
    2189
  • 访问量
    12690138