大量資料快速插入方法探究[nologging+parallel+append]

來源:互聯網
上載者:User

標籤:append   parallel   nologging   

大量資料快速插入方法探究

快速插入千萬層級的資料,無非就是nologging+parallel+append

1     環境搭建

構建一個千萬層級的源表,向一個空表insert操作。

參考指標:insert動作完成的實際時間。

SQL> drop table test_emp cascadeconstraints purge;Table dropped.SQL> create table test_emp as select *from emp;Table created.SQL> begin 2  for i in 1..10 loop 3  insert into test_emp select *from test_emp;   --批量dml,建議forall 4  end loop; 5  end; 6  /PL/SQL procedure successfully completed.SQL> select count(*) from test_emp; COUNT(*)----------    14336SQL> begin 2  for i in 1..10 loop 3  insert into test_emp select *from test_emp; 4  end loop 5  ; 6  end; 7  /PL/SQL procedure successfully completed.SQL> select count(*) from test_emp;  COUNT(*)---------- 14680064            --1.5千萬層級


2     only append
SQL> set timing onSQL> show timingtiming ONSQL> insert /*+ append */ into test_goalselect * from test_emp;14680064 rows created.

Elapsed: 00:00:20.72

沒有關閉日誌,所以時間是最長的。

3     append+nologging
SQL> truncate table test_goal;Table truncated.Elapsed: 00:00:00.11SQL> insert /*+ append */ into test_goalselect * from test_emp nologging;14680064 rows created.

Elapsed: 00:00:04.82

發現日誌對插入的影響很大,加nologging時間明顯大幅縮短;當然這個表沒有索引、約束等,這裡暫不考究。

4     append+nologging+parallel
SQL> truncate table test_goal;Table truncated. Elapsed: 00:00:00.09SQL> insert /*+ parallel(2) append */into test_goal select * from test_emp nologging;14680064 rows created.

Elapsed: 00:00:02.86

這裡在3的基礎上加上並行,效能基本達到極限,1.5千萬資料插入時間控制在3S左右。並行在伺服器效能支援的情況下,可以加大並行參數。


本文出自 “90SirDB” 部落格,請務必保留此出處http://90sirdb.blog.51cto.com/8713279/1794367

大量資料快速插入方法探究[nologging+parallel+append]

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.