這篇文章將為大家詳細(xì)講解有關(guān)數(shù)據(jù)庫(kù)中如何實(shí)現(xiàn)大量數(shù)據(jù)快速插入方法,小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。
創(chuàng)新互聯(lián)建站于2013年開(kāi)始,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目成都網(wǎng)站建設(shè)、成都網(wǎng)站制作網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢(mèng)想脫穎而出為使命,1280元江油做網(wǎng)站,已為上家服務(wù),為江油各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:13518219792
構(gòu)建一個(gè)千萬(wàn)級(jí)別的源表,向一個(gè)空表insert操作。
參考指標(biāo):insert動(dòng)作完成的實(shí)際時(shí)間。
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(*) ---------- 14336 SQL> 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千萬(wàn)級(jí)別
SQL> set timing on SQL> show timing timing ON SQL> insert /*+ append */ into test_goalselect * from test_emp; 14680064 rows created.
Elapsed: 00:00:20.72
沒(méi)有關(guān)閉日志,所以時(shí)間是最長(zhǎng)的。
SQL> truncate table test_goal; Table truncated. Elapsed: 00:00:00.11 SQL> insert /*+ append */ into test_goalselect * from test_emp nologging; 14680064 rows created.
Elapsed: 00:00:04.82
發(fā)現(xiàn)日志對(duì)插入的影響很大,加nologging時(shí)間明顯大幅縮短;當(dāng)然這個(gè)表沒(méi)有索引、約束等,這里暫不考究。
SQL> truncate table test_goal; Table truncated. Elapsed: 00:00:00.09 SQL> insert /*+ parallel(2) append */into test_goal select * from test_emp nologging; 14680064 rows created.
Elapsed: 00:00:02.86
這里在3的基礎(chǔ)上加上并行,性能基本達(dá)到極限,1.5千萬(wàn)數(shù)據(jù)插入時(shí)間控制在3S左右。并行在服務(wù)器性能支持的情況下,可以加大并行參數(shù)。
關(guān)于“數(shù)據(jù)庫(kù)中如何實(shí)現(xiàn)大量數(shù)據(jù)快速插入方法”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),請(qǐng)把它分享出去讓更多的人看到。
本文名稱:數(shù)據(jù)庫(kù)中如何實(shí)現(xiàn)大量數(shù)據(jù)快速插入方法
URL地址:http://chinadenli.net/article46/jiishg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)頁(yè)設(shè)計(jì)公司、品牌網(wǎng)站設(shè)計(jì)、網(wǎng)站營(yíng)銷、面包屑導(dǎo)航、做網(wǎng)站、網(wǎng)站內(nèi)鏈
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)