merge into三種表連線方式的效能比較(一)

wisdomone1發表於2012-12-10
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部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-750844/,如需轉載,請註明出處,否則將追究法律責任。

相關文章