WITH VALIDATION 與WITHOUT VALIDATION對分割槽交換的影響
最近將一個比較大的歷史表改造為分割槽表,中間用到了分割槽交換,為了搞清楚分割槽交換時WITHOUT VALIDATION與WITH VALIDATION以及是否禁用主鍵約束的區別,
用10046對各種情況進行了跟蹤對比:
1.禁用主鍵約束+without validation
ALTER TABLE BC_LOG_TRANSFER_EB_HIS1 DISABLE CONSTRAINT PK_LOG_TRANSFER_EB_HIS KEEP INDEX;
alter session set events '10046 trace name context forever,level 12';
ALTER TABLE BC_LOG_TRANSFER_EB_HIS1 EXCHANGE PARTITION P201304 WITH TABLE BC_LOG_TRANSFER_EB_HIS0 INCLUDING INDEXES WITHOUT VALIDATION;
alter session set events '10046 trace name context off';
ALTER TABLE BC_LOG_TRANSFER_EB_HIS1 ENABLE CONSTRAINT PK_LOG_TRANSFER_EB_HIS;
***********************************************************************************************
OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 59 0.02 0.02 0 0 0 0
Execute 76 0.06 0.12 5 59 39 16
Fetch 69 0.02 0.26 26 138 0 69
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 204 0.11 0.41 31 197 39 85
Misses in library cache during parse: 9
Misses in library cache during execute: 6
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
Disk file operations I/O 6 0.00 0.00
db file sequential read 31 0.03 0.30
2.不禁用主鍵約束+without validation
alter session set events '10046 trace name context forever,level 12';
ALTER TABLE BC_LOG_TRANSFER_EB_HIS1 EXCHANGE PARTITION P201304 WITH TABLE BC_LOG_TRANSFER_EB_HIS0 INCLUDING INDEXES WITHOUT VALIDATION;
alter session set events '10046 trace name context off';
******************************************************************************
OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 56 0.02 0.02 0 0 0 0
Execute 67 0.04 0.16 6 59 39 16
Fetch 47 2.28 2.92 2408 26711 1 31
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 170 2.36 3.11 2414 26770 40 47
Misses in library cache during parse: 4
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
Disk file operations I/O 7 0.04 0.04
db file scattered read 1 0.01 0.01
db file sequential read 2407 0.07 0.98
select /*+ first_rows(1) ordered */ 1
from
"SYS"."BC_LOG_TRANSFER_EB_HIS0" A ,"SYS"."BC_LOG_TRANSFER_EB_HIS1" B where
"A"."CREDIT_ID" = "B"."CREDIT_ID" and "A"."TRAN_DATE" = "B"."TRAN_DATE" and
"A"."CHANNEL" = "B"."CHANNEL" and (
tbl$or$idx$part$num("SYS"."BC_LOG_TRANSFER_EB_HIS1",0,0,0 ,B .rowid ) < 4
or tbl$or$idx$part$num("SYS"."BC_LOG_TRANSFER_EB_HIS1",0,0,0 ,B .rowid )
> 4 ) and tbl$or$idx$part$num("SYS"."BC_LOG_TRANSFER_EB_HIS1",0,0,0 ,A
.TRAN_DATE ) <> 4 and rownum < 2
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.01 0.01 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 2.27 2.84 2399 26652 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 3 2.28 2.85 2399 26652 0 0
Misses in library cache during parse: 1
Optimizer mode: FIRST_ROWS
Parsing user id: SYS (recursive depth: 1)
Number of plan statistics captured: 1
Rows (1st) Rows (avg) Rows (max) Row Source Operation
---------- ---------- ---------- ---------------------------------------------------
0 0 0 COUNT STOPKEY (cr=26652 pr=2399 pw=0 time=2842034 us)
0 0 0 NESTED LOOPS (cr=26652 pr=2399 pw=0 time=2842009 us cost=0 size=128 card=2)
0 0 0 INDEX FULL SCAN PK_LOG_TRANSFER_EB_HIS0 (cr=26652 pr=2399 pw=0 time=2842003 us cost=0 size=78 card=3)(object id 80228)
0 0 0 PARTITION RANGE ITERATOR PARTITION: KEY KEY (cr=0 pr=0 pw=0 time=0 us cost=0 size=38 card=1)
0 0 0 INDEX UNIQUE SCAN PK_LOG_TRANSFER_EB_HIS PARTITION: KEY KEY (cr=0 pr=0 pw=0 time=0 us cost=0 size=38 card=1)(object id 80177)
3.不禁用主鍵約束+with validation
alter session set events '10046 trace name context forever,level 12';
ALTER TABLE BC_LOG_TRANSFER_EB_HIS1 EXCHANGE PARTITION P201304 WITH TABLE BC_LOG_TRANSFER_EB_HIS0 INCLUDING INDEXES WITH VALIDATION;
alter session set events '10046 trace name context off';
************************************************************************************
OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 56 0.01 0.02 0 0 0 0
Execute 83 0.08 0.15 5 59 39 16
Fetch 63 1.76 24.95 12224 13159 1 207
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 202 1.87 25.12 12229 13218 40 223
Misses in library cache during parse: 9
Misses in library cache during execute: 7
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
Disk file operations I/O 7 1.27 1.27
db file sequential read 11 1.88 5.88
db file scattered read 113 2.12 15.05
select 1
from
"BC_LOG_TRANSFER_EB_HIS0" where
TBL$OR$IDX$PART$NUM("BC_LOG_TRANSFER_EB_HIS1", 0, 3,1048576,"TRAN_DATE") !=
:1
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 1.74 17.38 12218 13055 1 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 3 1.75 17.38 12218 13055 1 0
Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: CHOOSE
Parsing user id: SYS (recursive depth: 1)
Number of plan statistics captured: 1
Rows (1st) Rows (avg) Rows (max) Row Source Operation
---------- ---------- ---------- ---------------------------------------------------
0 0 0 TABLE ACCESS FULL BC_LOG_TRANSFER_EB_HIS0 (cr=13055 pr=12218 pw=0 time=17383845 us)
用10046對各種情況進行了跟蹤對比:
1.禁用主鍵約束+without validation
ALTER TABLE BC_LOG_TRANSFER_EB_HIS1 DISABLE CONSTRAINT PK_LOG_TRANSFER_EB_HIS KEEP INDEX;
alter session set events '10046 trace name context forever,level 12';
ALTER TABLE BC_LOG_TRANSFER_EB_HIS1 EXCHANGE PARTITION P201304 WITH TABLE BC_LOG_TRANSFER_EB_HIS0 INCLUDING INDEXES WITHOUT VALIDATION;
alter session set events '10046 trace name context off';
ALTER TABLE BC_LOG_TRANSFER_EB_HIS1 ENABLE CONSTRAINT PK_LOG_TRANSFER_EB_HIS;
***********************************************************************************************
OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 59 0.02 0.02 0 0 0 0
Execute 76 0.06 0.12 5 59 39 16
Fetch 69 0.02 0.26 26 138 0 69
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 204 0.11 0.41 31 197 39 85
Misses in library cache during parse: 9
Misses in library cache during execute: 6
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
Disk file operations I/O 6 0.00 0.00
db file sequential read 31 0.03 0.30
2.不禁用主鍵約束+without validation
alter session set events '10046 trace name context forever,level 12';
ALTER TABLE BC_LOG_TRANSFER_EB_HIS1 EXCHANGE PARTITION P201304 WITH TABLE BC_LOG_TRANSFER_EB_HIS0 INCLUDING INDEXES WITHOUT VALIDATION;
alter session set events '10046 trace name context off';
******************************************************************************
OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 56 0.02 0.02 0 0 0 0
Execute 67 0.04 0.16 6 59 39 16
Fetch 47 2.28 2.92 2408 26711 1 31
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 170 2.36 3.11 2414 26770 40 47
Misses in library cache during parse: 4
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
Disk file operations I/O 7 0.04 0.04
db file scattered read 1 0.01 0.01
db file sequential read 2407 0.07 0.98
select /*+ first_rows(1) ordered */ 1
from
"SYS"."BC_LOG_TRANSFER_EB_HIS0" A ,"SYS"."BC_LOG_TRANSFER_EB_HIS1" B where
"A"."CREDIT_ID" = "B"."CREDIT_ID" and "A"."TRAN_DATE" = "B"."TRAN_DATE" and
"A"."CHANNEL" = "B"."CHANNEL" and (
tbl$or$idx$part$num("SYS"."BC_LOG_TRANSFER_EB_HIS1",0,0,0 ,B .rowid ) < 4
or tbl$or$idx$part$num("SYS"."BC_LOG_TRANSFER_EB_HIS1",0,0,0 ,B .rowid )
> 4 ) and tbl$or$idx$part$num("SYS"."BC_LOG_TRANSFER_EB_HIS1",0,0,0 ,A
.TRAN_DATE ) <> 4 and rownum < 2
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.01 0.01 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 2.27 2.84 2399 26652 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 3 2.28 2.85 2399 26652 0 0
Misses in library cache during parse: 1
Optimizer mode: FIRST_ROWS
Parsing user id: SYS (recursive depth: 1)
Number of plan statistics captured: 1
Rows (1st) Rows (avg) Rows (max) Row Source Operation
---------- ---------- ---------- ---------------------------------------------------
0 0 0 COUNT STOPKEY (cr=26652 pr=2399 pw=0 time=2842034 us)
0 0 0 NESTED LOOPS (cr=26652 pr=2399 pw=0 time=2842009 us cost=0 size=128 card=2)
0 0 0 INDEX FULL SCAN PK_LOG_TRANSFER_EB_HIS0 (cr=26652 pr=2399 pw=0 time=2842003 us cost=0 size=78 card=3)(object id 80228)
0 0 0 PARTITION RANGE ITERATOR PARTITION: KEY KEY (cr=0 pr=0 pw=0 time=0 us cost=0 size=38 card=1)
0 0 0 INDEX UNIQUE SCAN PK_LOG_TRANSFER_EB_HIS PARTITION: KEY KEY (cr=0 pr=0 pw=0 time=0 us cost=0 size=38 card=1)(object id 80177)
3.不禁用主鍵約束+with validation
alter session set events '10046 trace name context forever,level 12';
ALTER TABLE BC_LOG_TRANSFER_EB_HIS1 EXCHANGE PARTITION P201304 WITH TABLE BC_LOG_TRANSFER_EB_HIS0 INCLUDING INDEXES WITH VALIDATION;
alter session set events '10046 trace name context off';
************************************************************************************
OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 56 0.01 0.02 0 0 0 0
Execute 83 0.08 0.15 5 59 39 16
Fetch 63 1.76 24.95 12224 13159 1 207
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 202 1.87 25.12 12229 13218 40 223
Misses in library cache during parse: 9
Misses in library cache during execute: 7
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
Disk file operations I/O 7 1.27 1.27
db file sequential read 11 1.88 5.88
db file scattered read 113 2.12 15.05
select 1
from
"BC_LOG_TRANSFER_EB_HIS0" where
TBL$OR$IDX$PART$NUM("BC_LOG_TRANSFER_EB_HIS1", 0, 3,1048576,"TRAN_DATE") !=
:1
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 1.74 17.38 12218 13055 1 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 3 1.75 17.38 12218 13055 1 0
Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: CHOOSE
Parsing user id: SYS (recursive depth: 1)
Number of plan statistics captured: 1
Rows (1st) Rows (avg) Rows (max) Row Source Operation
---------- ---------- ---------- ---------------------------------------------------
0 0 0 TABLE ACCESS FULL BC_LOG_TRANSFER_EB_HIS0 (cr=13055 pr=12218 pw=0 time=17383845 us)
結論:
1.當禁用主鍵約束,不進行validation時,分割槽交換僅是資料字典級的操作,不會對錶或索引進行掃描
2.當不禁用主鍵約束,進行validation時,分割槽交換需要對錶進行全表掃描,來做validation。
3.當不禁用主鍵約束,不進行validation時,分割槽交換需要對主鍵索引進行掃描來完成主鍵約束的校驗。
因此,只有在禁用主鍵約束並不進行validation時,分割槽交換才是效率最快的。
1.當禁用主鍵約束,不進行validation時,分割槽交換僅是資料字典級的操作,不會對錶或索引進行掃描
2.當不禁用主鍵約束,進行validation時,分割槽交換需要對錶進行全表掃描,來做validation。
3.當不禁用主鍵約束,不進行validation時,分割槽交換需要對主鍵索引進行掃描來完成主鍵約束的校驗。
因此,只有在禁用主鍵約束並不進行validation時,分割槽交換才是效率最快的。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10972173/viewspace-1069992/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 交換分割槽之without validation
- 【SQL】Oracle交換分割槽中引數without validation引發的症狀(二)SQLOracle
- 【SQL】Oracle交換分割槽中引數without validation引發的症狀(一)SQLOracle
- oracle本地分割槽索引跨分割槽對成本的影響Oracle索引
- 分割槽表的不同操作對索引的影響索引
- 操作分割槽表對global和local索引的影響索引
- 在範圍分割槽表上分割槽維護操作對索引狀態的影響索引
- dubbo~javax.validation和jakarta.validation的介紹與排雷Java
- 在範圍分割槽表上分割槽維護操作對索引狀態的影響(1)索引
- oracle分割槽表的常規操作導致對索引的影響Oracle索引
- Laravel model validationLaravel
- Java Bean ValidationJavaBean
- oracle之分割槽交換Oracle
- unbuntu新增交換分割槽
- linux交換分割槽Linux
- 全面學習分割槽表及分割槽索引(10)--交換分割槽索引
- Seven 儲存結構與磁碟劃分 主分割槽交換分割槽的作用!
- 在範圍分割槽表上分割槽維護操作對全域性及本地索引狀態的影響(2)索引
- Spring Validation 的使用Spring
- jquery-validation的使用jQuery
- Ubuntu 啟用交換分割槽Ubuntu
- 分割槽表的分割槽資料刪除、truncate會對全域性和區域性索引產生什麼影響索引
- 有關Oracle表分割槽進行(DML)維護後對索引的影響的分析Oracle索引
- ASP.NET MVC ValidationASP.NETMVC
- linux交換分割槽調整Linux
- oracle分割槽交換(exchange)技術Oracle
- 擴充套件aix交換分割槽套件AI
- Oracle Vs MsSQL 之交換分割槽OracleSQL
- aix擴充 交換分割槽的步驟AI
- 伺服器字符集對DM7中List分割槽表使用中文的影響伺服器
- SSD固態硬碟要分割槽嗎?SSD固態硬碟分割槽與不分割槽的效能對比硬碟
- 理解「交叉驗證」(Cross Validation)ROS
- datafilecopy header validation failure problemHeaderAI
- 雲端計算:交換分割槽管理 Swap
- 使用split對分割槽表再分割槽
- AIX 管理交換分割槽經常用到的命令AI
- Hive的靜態分割槽與動態分割槽Hive
- 範圍分割槽表和INTERVAL分割槽表對於SPLIT分割槽的區別