使用sqlloader的直接載入方式和傳統載入方式的效能差異
Direct 直接載入特點
(1)資料繞過SGA直接寫入磁碟的資料檔案
(2)資料直接寫入高水位線HWM之後的新塊,不會掃描HWM之前的空閒塊
(3)commit之後移動HWM他人才能看到
(4)不對已用空間進行掃描
(5)使用direct幾乎不產生redo log,不是完全不產生(安全性差),但會產生undo資料
(6)適用OLAP線上分析場景,增 刪 改不頻繁的場景
Conventional傳統載入特點
(1)資料先載入 -> SGA -> 磁碟的資料檔案
(2)會掃描高水位線HWM之前的資料塊,如果有空閒塊(碎片經常DML導致)就會利用,如果沒有再插入新塊
(3)高水位線HWM之前的資料塊是放在SGA區的
(4)會產生redo log和undo資料
(5)安全性高,可恢復資料
(6)傳統載入與SQL語句insert插入沒區別
1.建立一個文字資料
BYS@ bys001>set termout off;BYS@ bys001>set feedback off;
BYS@ bys001>set echo off;
BYS@ bys001>set heading off;
BYS@ bys001>set trimout on;
BYS@ bys001>set trimspool on;
BYS@ bys001>spool /home/oracle/sqlload.txt
BYS@ bys001>select owner||','||object_name||','||object_id from dba_objects;
BYS@ bys001>spool off;
此時退出SQLPLUS,到/home/oracle/ 下檢視
[oracle@oel-01 ~]$ tail sqlload.txt
SCOTT,TEST_AUDIT,75940
SYS,WRH$_ACTIVE_SESSION_HISTORY,76484
SYS,WRH$_TABLESPACE_STAT,76488
BYS@ bys001>spool off;
[oracle@oel-01 ~]$ vi sqlload.txt
輸入 shift + g 將游標定位到最後一行,刪除BYS@ bys001>spool off; 這一行,儲存退出。
[oracle@oel-01 ~]$ cat sqlload.txt | wc -l
72893
2.資料庫中建立表,OS中建立SQL*LOADER的控制檔案
BYS@ bys001>create table test1(owner varchar2(30),object_name varchar2(150),object_id number);Table created.
建立控制檔案,內容如下
[oracle@oel-01 ~]$ cat sqlload.ctl
load data
infile '/home/oracle/sqlload.txt'
badfile '/home/oracle/sqlload_bad.txt'
discardfile '/home/oracle/sqlload_discard.txt'
append into table test1
fields terminated by ","
trailing nullcols
(owner,object_name,object_id)
3.開始載入,使用直接載入方法,用時約1秒
[oracle@oel-01 ~]$ sqlldr bys/bys control=sqlload.ctl log=sqlload.log direct=trueSQL*Loader: Release 11.2.0.1.0 - Production on Mon Jul 29 10:10:06 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Load completed - logical record count 72893.
日誌如下:
[oracle@oel-01 ~]$ cat sqlload.log
SQL*Loader: Release 11.2.0.1.0 - Production on Mon Jul 29 10:10:06 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Control File: sqlload.ctl
Data File: /home/oracle/sqlload.txt
Bad File: /home/oracle/sqlload_bad.txt
Discard File: /home/oracle/sqlload_discard.txt
(Allow all discards)
Number to load: ALL
Number to skip: 0
Errors allowed: 50
Continuation: none specified
Path used: Direct
Table TEST1, loaded from every logical record.
Insert option in effect for this table: APPEND
TRAILING NULLCOLS option in effect
Column Name Position Len Term Encl Datatype
------------------------------ ---------- ----- ---- ---- ---------------------
OWNER FIRST * , CHARACTER
OBJECT_NAME NEXT * , CHARACTER
OBJECT_ID NEXT * , CHARACTER
Record 2: Discarded - all columns null.
Record 1: Rejected - Error on table TEST1, column OBJECT_ID.
ORA-01722: invalid number
Record 10001: Discarded - all columns null.
Record 20000: Discarded - all columns null.
Record 29999: Discarded - all columns null.
Record 39998: Discarded - all columns null.
Record 49997: Discarded - all columns null.
Record 59996: Discarded - all columns null.
Record 69995: Discarded - all columns null.
Table TEST1:
72884 Rows successfully loaded.
1 Row not loaded due to data errors.
0 Rows not loaded because all WHEN clauses were failed.
8 Rows not loaded because all fields were null.
Bind array size not used in direct path.
Column array rows : 5000
Stream buffer bytes: 256000
Read buffer bytes: 1048576
Total logical records skipped: 0
Total logical records read: 72893
Total logical records rejected: 1
Total logical records discarded: 8
Total stream buffers loaded by SQL*Loader main thread: 16
Total stream buffers loaded by SQL*Loader load thread: 0
Run began on Mon Jul 29 10:10:06 2013
Run ended on Mon Jul 29 10:10:07 2013
Elapsed time was: 00:00:00.99
CPU time was: 00:00:00.12
用時約1秒
4.使用傳統載入方法:用時3秒
[oracle@oel-01 ~]$ echo 1>sqlload.log在SQLPLUS中刪除表中資料。
BYS@ bys001>select count(*) from test1;
COUNT(*)
----------
72884
BYS@ bys001>truncate table test1;
[oracle@oel-01 ~]$ sqlldr bys/bys control=sqlload.ctl log=sqlload.log
在SQLPLUS中檢視:
BYS@ bys001>select count(*) from test1;
COUNT(*)
----------
72884
[oracle@oel-01 ~]$ cat sqlload.log
SQL*Loader: Release 11.2.0.1.0 - Production on Mon Jul 29 10:12:17 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Control File: sqlload.ctl
Data File: /home/oracle/sqlload.txt
Bad File: /home/oracle/sqlload_bad.txt
Discard File: /home/oracle/sqlload_discard.txt
(Allow all discards)
Number to load: ALL
Number to skip: 0
Errors allowed: 50
Bind array: 64 rows, maximum of 256000 bytes
Continuation: none specified
Path used: Conventional
Table TEST1, loaded from every logical record.
Insert option in effect for this table: APPEND
TRAILING NULLCOLS option in effect
Column Name Position Len Term Encl Datatype
------------------------------ ---------- ----- ---- ---- ---------------------
OWNER FIRST * , CHARACTER
OBJECT_NAME NEXT * , CHARACTER
OBJECT_ID NEXT * , CHARACTER
Record 2: Discarded - all columns null.
Record 1: Rejected - Error on table TEST1, column OBJECT_ID.
ORA-01722: invalid number
Record 10001: Discarded - all columns null.
Record 20000: Discarded - all columns null.
Record 29999: Discarded - all columns null.
Record 39998: Discarded - all columns null.
Record 49997: Discarded - all columns null.
Record 59996: Discarded - all columns null.
Record 69995: Discarded - all columns null.
Table TEST1:
72884 Rows successfully loaded.
1 Row not loaded due to data errors.
0 Rows not loaded because all WHEN clauses were failed.
8 Rows not loaded because all fields were null.
Space allocated for bind array: 49536 bytes(64 rows)
Read buffer bytes: 1048576
Total logical records skipped: 0
Total logical records read: 72893
Total logical records rejected: 1
Total logical records discarded: 8
Run began on Mon Jul 29 10:12:17 2013
Run ended on Mon Jul 29 10:12:20 2013
Elapsed time was: 00:00:02.97
CPU time was: 00:00:00.35
相關文章
- 【原創】比較使用sql*loader的直接載入方式和傳統載入方式的效能差異SQL
- View的載入原理和攔截方式View
- 小說APP原始碼的圖片載入方式,懶載入和預載入的實現APP原始碼
- 多重載入Bean方式Bean
- 載入圖片方式
- 關於angularjs的載入方式AngularJS
- Vue中圖片的載入方式Vue
- 現代化懶載入的方式
- OpenSSL Engine的三種載入方式
- 效能更優越的小程式圖片懶載入方式
- JavaScript 檔案載入方式JavaScript
- 使用jQuery和YQL,以Ajax方式載入外部內容jQuery
- Python頁面載入的等待方式Python
- 不一樣的圖片載入方式
- spring 載入配置檔案的方式Spring
- 前端效能優化(四)——網頁載入更快的N種方式前端優化網頁
- 直接載入和並行記載-01並行
- 一對一聊天軟體原始碼,提升系統效能的圖片載入方式原始碼
- tensorflow載入資料的三種方式
- 谷歌:如何以最高效的方式載入 WebAssembly谷歌Web
- 直接載入和並行-02並行
- HBase協處理器載入的三種方式
- 實現圖片懶載入的三種方式
- 並行直接載入和系統調整的一點思路並行
- 請教關於spring 兩種組合載入方式的使用?Spring
- spring bean定義與載入方式SpringBean
- unity3D AssetBundle載入方式Unity3D
- iOS彈幕高效載入實現方式iOS
- 淺析SpringBoot載入配置的6種方式Spring Boot
- 從Xib檔案載入UIView的5種方式UIView
- asp.net載入新浪方式的圖片輪播ASP.NET
- 談談MES系統差異產生的主要方式
- Oracle 【直接載入】全方位解析與效能優化Oracle優化
- 在 PowerShell 中,"本地載入"和"遠端載入"通常指的是執行指令碼或命令的位置或方式。以下是關於本地載入和遠端載入的一些基本概念和示例:指令碼
- 前端效能優化——延遲載入和非同步載入前端優化非同步
- 效能優化 (五) 長圖優化,仿微博載入長圖方式優化
- 使用awk查詢不滿足sqlloader載入條件的記錄SQL
- Element UI table 非同步載入,使用其他方式觸發UI非同步