Oracle 12c中db_file_multiblock_read_count 引數引發的效能問題
最近有一套系統一條簡單的語句執行很慢:create table xxx as select * from xxx;
做了簡單的10046如下:
SQL ID: 479aa0z9yttdr Plan Hash: 2897757325
create table CRE000_HR_DM
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.01 0.24 12 36 0 0
Execute 1 7.21 18.24 29867 30189 33465 3032342
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 2 7.22 18.48 29879 30225 33465 3032342
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: SYS
Number of plan statistics captured: 1
Rows (1st) Rows (avg) Rows (max) Row Source Operation
---------- ---------- ---------- ---------------------------------------------------
0 0 0 LOAD AS SELECT (cr=30161 pr=29868 pw=29863 time=18243403 us)
3032342 3032342 3032342 OPTIMIZER STATISTICS GATHERING (cr=29868 pr=29864 pw=0 time=11393334 us cost=8190 size=200134572 card=3032342)
3032342 3032342 3032342 TABLE ACCESS FULL TEST01 (cr=29868 pr=29864 pw=0 time=7556276 us cost=8190 size=200134572 card=3032342)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
library cache lock 1 0.00 0.00
row cache lock 25 0.00 0.01
library cache pin 1 0.00 0.00
enq: IV - contention 7 0.00 0.00
db file sequential read 4 0.02 0.02
reliable message 7 0.00 0.01
enq: KO - fast object checkpoint 2 0.00 0.00
direct path read 1443 0.24 9.19
enq: TS - contention 1 0.00 0.00
gc current grant 2-way 6 0.00 0.00
enq: HW - contention 1 0.00 0.00
gc current grant busy 2 0.00 0.00
CSS initialization 2 0.00 0.00
CSS operation: query 6 0.00 0.00
CSS operation: action 2 0.00 0.00
direct path write 23 0.51 1.22
KJC: Wait for msg sends to complete 1 0.00 0.00
gc current multi block request 39 0.00 0.02
gc buffer busy acquire 1 0.34 0.34
gc current block lost 1 0.00 0.00
lock deadlock retry 1 0.00 0.00
gc current block busy 1 0.00 0.00
gc current block 2-way 1 0.00 0.00
log file switch completion 1 0.09 0.09
enq: RC - Result Cache: Contention 1 0.00 0.00
Disk file operations I/O 1 0.00 0.00
log file sync 1 0.07 0.07
SQL*Net message to client 1 0.00 0.00
SQL*Net message from client 1 15.17 15.17
********************************************************************************
在會話層做了
首先調整了oracle12C上最佳化器引數:
set optimizer_adaptive_features=false
接著繼續做10046檢視情況:
create table CRE000_HR_DM
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.15 9 27 0 0
Execute 1 7.52 13.29 29868 30189 33560 3032342
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 2 7.53 13.44 29877 30216 33560 3032342
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: SYS
Number of plan statistics captured: 1
Rows (1st) Rows (avg) Rows (max) Row Source Operation
---------- ---------- ---------- ---------------------------------------------------
0 0 0 LOAD AS SELECT (cr=30161 pr=29868 pw=29863 time=13265259 us)
3032342 3032342 3032342 OPTIMIZER STATISTICS GATHERING (cr=29868 pr=29864 pw=0 time=7046218 us cost=8190 size=200134572 card=3032342)
3032342 3032342 3032342 TABLE ACCESS FULL TEST01 (cr=29868 pr=29864 pw=0 time=3189042 us cost=8190 size=200134572 card=3032342)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
library cache lock 1 0.00 0.00
library cache pin 9 0.00 0.00
row cache lock 5 0.00 0.00
KJC: Wait for msg sends to complete 3 0.00 0.00
enq: IV - contention 7 0.00 0.00
db file sequential read 5 0.02 0.08
enq: KO - fast object checkpoint 3 0.00 0.00
reliable message 7 0.00 0.01
direct path read 3824 0.32 5.41
enq: TT - contention 4 0.00 0.00
gc current grant busy 10 0.01 0.01
gc current grant 2-way 4 0.00 0.00
enq: TS - contention 1 0.00 0.00
enq: HW - contention 1 0.00 0.00
direct path write 27 0.04 0.22
gc current multi block request 31 0.00 0.02
enq: RC - Result Cache: Contention 1 0.00 0.00
Disk file operations I/O 1 0.00 0.00
SQL*Net message to client 1 0.00 0.00
SQL*Net message from client 1 7.21 7.21
********************************************************************************
這一次direct path read仍然很高,統計收集小了很多,繼續對 direct path read 問題進行調整 :
透過與11g上執行情況的比較,12C除了時間長了很多 direct path read等待事件很場外沒有其他差異,檢查引數:
什麼是全表掃描?
全表掃描就是掃表表中所有的行,實際上是掃描表中所有的資料塊,oracle的最小單位是Oracle block。
掃描所有的資料塊就包括高水位線以內的資料塊,即使是空資料塊在沒有被釋放的情形下也會被掃描而導致I/O增加。
在全表掃描期間,通常情況下,表上這些相鄰的資料塊被按順序(sequentially)的方式訪問以使得一次I/O可以讀取多個資料塊。
一次讀取更多的資料塊有助於全表掃描使用更少的I/O,對於可讀取的資料塊被限制於引數DB_FILE_MULTIBLOCK_READ_COUNT
檢查引數:DB_FILE_MULTIBLOCK_READ_COUNT發現在改12C系統上,該引數值為2,果斷調整到128
然後繼續做10046:
create table CRE000_HR_DM
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.01 0.12 12 36 0 0
Execute 1 6.19 6.63 29869 30221 33979 3032342
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 2 6.21 6.76 29881 30257 33979 3032342
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: SYS
Number of plan statistics captured: 1
Rows (1st) Rows (avg) Rows (max) Row Source Operation
---------- ---------- ---------- ---------------------------------------------------
0 0 0 LOAD AS SELECT (cr=30193 pr=29872 pw=29863 time=6659863 us)
3032342 3032342 3032342 OPTIMIZER STATISTICS GATHERING (cr=29868 pr=29864 pw=0 time=4357814 us cost=5252 size=200134572 card=3032342)
3032342 3032342 3032342 TABLE ACCESS FULL TEST01 (cr=29868 pr=29864 pw=0 time=739219 us cost=5252 size=200134572 card=3032342)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
row cache lock 8 0.00 0.00
enq: IV - contention 7 0.00 0.00
Disk file operations I/O 3 0.00 0.00
db file sequential read 6 0.01 0.06
enq: KO - fast object checkpoint 3 0.00 0.00
KJC: Wait for msg sends to complete 4 0.00 0.00
reliable message 7 0.00 0.01
direct path read 19 0.06 0.23
gc current grant 2-way 21 0.00 0.01
enq: TS - contention 1 0.00 0.00
enq: HW - contention 1 0.00 0.00
CSS initialization 2 0.00 0.00
CSS operation: query 6 0.00 0.00
CSS operation: action 2 0.00 0.00
direct path write 11 0.00 0.02
gc current multi block request 31 0.00 0.03
enq: RC - Result Cache: Contention 3 0.00 0.00
SQL*Net message to client 1 0.00 0.00
SQL*Net message from client 1 4.47 4.47
********************************************************************************
問題終於解決了
做了簡單的10046如下:
SQL ID: 479aa0z9yttdr Plan Hash: 2897757325
create table CRE000_HR_DM
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.01 0.24 12 36 0 0
Execute 1 7.21 18.24 29867 30189 33465 3032342
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 2 7.22 18.48 29879 30225 33465 3032342
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: SYS
Number of plan statistics captured: 1
Rows (1st) Rows (avg) Rows (max) Row Source Operation
---------- ---------- ---------- ---------------------------------------------------
0 0 0 LOAD AS SELECT (cr=30161 pr=29868 pw=29863 time=18243403 us)
3032342 3032342 3032342 OPTIMIZER STATISTICS GATHERING (cr=29868 pr=29864 pw=0 time=11393334 us cost=8190 size=200134572 card=3032342)
3032342 3032342 3032342 TABLE ACCESS FULL TEST01 (cr=29868 pr=29864 pw=0 time=7556276 us cost=8190 size=200134572 card=3032342)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
library cache lock 1 0.00 0.00
row cache lock 25 0.00 0.01
library cache pin 1 0.00 0.00
enq: IV - contention 7 0.00 0.00
db file sequential read 4 0.02 0.02
reliable message 7 0.00 0.01
enq: KO - fast object checkpoint 2 0.00 0.00
direct path read 1443 0.24 9.19
enq: TS - contention 1 0.00 0.00
gc current grant 2-way 6 0.00 0.00
enq: HW - contention 1 0.00 0.00
gc current grant busy 2 0.00 0.00
CSS initialization 2 0.00 0.00
CSS operation: query 6 0.00 0.00
CSS operation: action 2 0.00 0.00
direct path write 23 0.51 1.22
KJC: Wait for msg sends to complete 1 0.00 0.00
gc current multi block request 39 0.00 0.02
gc buffer busy acquire 1 0.34 0.34
gc current block lost 1 0.00 0.00
lock deadlock retry 1 0.00 0.00
gc current block busy 1 0.00 0.00
gc current block 2-way 1 0.00 0.00
log file switch completion 1 0.09 0.09
enq: RC - Result Cache: Contention 1 0.00 0.00
Disk file operations I/O 1 0.00 0.00
log file sync 1 0.07 0.07
SQL*Net message to client 1 0.00 0.00
SQL*Net message from client 1 15.17 15.17
********************************************************************************
在會話層做了
首先調整了oracle12C上最佳化器引數:
set optimizer_adaptive_features=false
接著繼續做10046檢視情況:
create table CRE000_HR_DM
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.15 9 27 0 0
Execute 1 7.52 13.29 29868 30189 33560 3032342
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 2 7.53 13.44 29877 30216 33560 3032342
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: SYS
Number of plan statistics captured: 1
Rows (1st) Rows (avg) Rows (max) Row Source Operation
---------- ---------- ---------- ---------------------------------------------------
0 0 0 LOAD AS SELECT (cr=30161 pr=29868 pw=29863 time=13265259 us)
3032342 3032342 3032342 OPTIMIZER STATISTICS GATHERING (cr=29868 pr=29864 pw=0 time=7046218 us cost=8190 size=200134572 card=3032342)
3032342 3032342 3032342 TABLE ACCESS FULL TEST01 (cr=29868 pr=29864 pw=0 time=3189042 us cost=8190 size=200134572 card=3032342)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
library cache lock 1 0.00 0.00
library cache pin 9 0.00 0.00
row cache lock 5 0.00 0.00
KJC: Wait for msg sends to complete 3 0.00 0.00
enq: IV - contention 7 0.00 0.00
db file sequential read 5 0.02 0.08
enq: KO - fast object checkpoint 3 0.00 0.00
reliable message 7 0.00 0.01
direct path read 3824 0.32 5.41
enq: TT - contention 4 0.00 0.00
gc current grant busy 10 0.01 0.01
gc current grant 2-way 4 0.00 0.00
enq: TS - contention 1 0.00 0.00
enq: HW - contention 1 0.00 0.00
direct path write 27 0.04 0.22
gc current multi block request 31 0.00 0.02
enq: RC - Result Cache: Contention 1 0.00 0.00
Disk file operations I/O 1 0.00 0.00
SQL*Net message to client 1 0.00 0.00
SQL*Net message from client 1 7.21 7.21
********************************************************************************
這一次direct path read仍然很高,統計收集小了很多,繼續對 direct path read 問題進行調整 :
透過與11g上執行情況的比較,12C除了時間長了很多 direct path read等待事件很場外沒有其他差異,檢查引數:
什麼是全表掃描?
全表掃描就是掃表表中所有的行,實際上是掃描表中所有的資料塊,oracle的最小單位是Oracle block。
掃描所有的資料塊就包括高水位線以內的資料塊,即使是空資料塊在沒有被釋放的情形下也會被掃描而導致I/O增加。
在全表掃描期間,通常情況下,表上這些相鄰的資料塊被按順序(sequentially)的方式訪問以使得一次I/O可以讀取多個資料塊。
一次讀取更多的資料塊有助於全表掃描使用更少的I/O,對於可讀取的資料塊被限制於引數DB_FILE_MULTIBLOCK_READ_COUNT
檢查引數:DB_FILE_MULTIBLOCK_READ_COUNT發現在改12C系統上,該引數值為2,果斷調整到128
然後繼續做10046:
create table CRE000_HR_DM
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.01 0.12 12 36 0 0
Execute 1 6.19 6.63 29869 30221 33979 3032342
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 2 6.21 6.76 29881 30257 33979 3032342
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: SYS
Number of plan statistics captured: 1
Rows (1st) Rows (avg) Rows (max) Row Source Operation
---------- ---------- ---------- ---------------------------------------------------
0 0 0 LOAD AS SELECT (cr=30193 pr=29872 pw=29863 time=6659863 us)
3032342 3032342 3032342 OPTIMIZER STATISTICS GATHERING (cr=29868 pr=29864 pw=0 time=4357814 us cost=5252 size=200134572 card=3032342)
3032342 3032342 3032342 TABLE ACCESS FULL TEST01 (cr=29868 pr=29864 pw=0 time=739219 us cost=5252 size=200134572 card=3032342)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
row cache lock 8 0.00 0.00
enq: IV - contention 7 0.00 0.00
Disk file operations I/O 3 0.00 0.00
db file sequential read 6 0.01 0.06
enq: KO - fast object checkpoint 3 0.00 0.00
KJC: Wait for msg sends to complete 4 0.00 0.00
reliable message 7 0.00 0.01
direct path read 19 0.06 0.23
gc current grant 2-way 21 0.00 0.01
enq: TS - contention 1 0.00 0.00
enq: HW - contention 1 0.00 0.00
CSS initialization 2 0.00 0.00
CSS operation: query 6 0.00 0.00
CSS operation: action 2 0.00 0.00
direct path write 11 0.00 0.02
gc current multi block request 31 0.00 0.03
enq: RC - Result Cache: Contention 3 0.00 0.00
SQL*Net message to client 1 0.00 0.00
SQL*Net message from client 1 4.47 4.47
********************************************************************************
問題終於解決了
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28612416/viewspace-2131375/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle中db_file_multiblock_read_count引數探究OracleBloC
- Oracle Extent引數問題Oracle
- oracle 效能引數Oracle
- reflow和repaint引發的效能問題AI
- Oracle 12C TDE問題引發DG不同步案例分析Oracle
- oracle 10g的db_file_multiblock_read_count引數Oracle 10gBloC
- DB_FILE_MULTIBLOCK_READ_COUNT引數和區間尺寸的設定問題BloC
- Oracle 12C 中CDB和PDB的引數檔案管理Oracle
- sql server datediff函式引發的效能問題SQLServer函式
- Oracle歸檔引數設定問題Oracle
- oracle 升級12c引數樣例Oracle
- 優化案例--重建索引引發的sql效能問題優化索引SQL
- Python中func(*args, **kwargs)的引數問題Python
- 一個引數引發的PDB無法在DataGuard下同步的問題
- C# 中的 in 引數和效能分析C#
- JS中缺少分號可能引發的問題JS
- Oracle引數-隱藏引數Oracle
- Druid連線池引數maxWait配置錯誤引發的問題UIAI
- oracle控制檔案及引數檔案問題Oracle
- 【SQL】Oracle交換分割槽中引數without validation引發的症狀(二)SQLOracle
- 【SQL】Oracle交換分割槽中引數without validation引發的症狀(一)SQLOracle
- oracle中的processes,session,transaction引數OracleSession
- Sqlldr效能引數SQL
- linux kernel引發的oracle問題及解決LinuxOracle
- Laravel 框架中 whereRaw like 引數繫結問題Laravel框架
- Java中形式引數與返回值問題Java
- SQL SERVER資料庫datediff函式引發的效能問題SQLServer資料庫函式
- log4j2同步日誌引發的效能問題
- 一次TiDB GC阻塞引發的效能問題分析TiDBGC
- Django ORM 引發的資料庫 N+1 效能問題DjangoORM資料庫
- 關於db_file_multiblock_read_count引數的設定BloC
- Oracle中INITRANS和MAXTRANS引數Oracle
- oracle 引數Oracle
- js中 函式引數的 傳值/傳引用 問題JS函式
- 【中亦安圖】導致Oracle效能抖動的引數提醒(4)Oracle
- C#中的值引數,引用引數及輸出引數C#
- 查詢oracle中的隱形引數Oracle
- Oracle升級中的引數補充Oracle