Oracle Study之--Oracle等待事件(3)
Db file parallel read
這是一個很容易引起誤導的等待事件,實際上這個等待事件和并行操作(比如并行查詢,并行DML)沒有關系。 這個事件發生在數據庫恢復的時候,當有一些數據塊需要恢復的時候,Oracle會以并行的方式把他們從數據文件中讀入到內存中進行恢復操作。
這個等待事件包含三個參數:
Files: 操作需要讀取的文件個數。
Blocks: 操作需要讀取的數據塊個數。
Requests: 操作需要執行的I/O次數。
案例分析:
11:06:16 SYS@ prod>conn scott/tiger Connected. 11:06:19 SCOTT@ prod>insert into emp1 select * from emp1; 286720 rows created. Elapsed: 00:00:02.04 11:07:22 SCOTT@ prod>/ 573440 rows created. 11:08:07 SYS@ prod>r 1 select event,TOTAL_WAITS,AVERAGE_WAIT from v$system_event 2* where upper(event) like 'DB FILE%' EVENT TOTAL_WAITS AVERAGE_WAIT ---------------------------------------------------------------- ----------- ------------ db file sequential read 4449 .04 db file scattered read 1650 .02 db file single write 36 .39 db file async I/O submit 133 8.69 db file parallel read 37 .19 Elapsed: 00:00:00.02 11:08:20 SYS@ prod>r 1 select event,TOTAL_WAITS,AVERAGE_WAIT from v$system_event 2* where upper(event) like 'DB FILE%' EVENT TOTAL_WAITS AVERAGE_WAIT ---------------------------------------------------------------- ----------- ------------ db file sequential read 7561 .03 db file scattered read 1785 .02 db file single write 36 .39 db file async I/O submit 160 10.29 db file parallel read 39 .19 Elapsed: 00:00:00.02
Db file parallel write
這是一個后臺等待事件,它同樣和用戶的并行操作沒有關系,它是由后臺進程DBWR產生的,當后臺進程DBWR向磁盤上寫入臟數據時,會發生這個等待。
DBWR會批量地將臟數據并行地寫入到磁盤上相應的數據文件中,在這個批次作業完成之前,DBWR將出現這個等待事件。如果僅僅是這一個等待事件,對用戶的操作并沒有太大的影響,當伴隨著出現free buffer waits等待事件時,說明此時內存中可用的空間不足,這時候會影響到用戶的操作,比如影響到用戶將臟數據塊讀入到內存中。
當出現db file parallel write等待事件時,可以通過啟用操作系統的異步I/O的方式來緩解這個等待。當使用異步I/O時,DBWR不再需要一直等到所有數據塊全部寫入到磁盤上,它只需要等到這個數據寫入到一個百分比之后,就可以繼續進行后續的操作。
這個等待事件有兩個參數:
Requests: 操作需要執行的I/O次數。
Timeouts: 等待的超時時間。
案例分析:
1、關閉ASYNC I/O:
11:25:47 SYS@ prod>show parameter sync
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
disk_asynch_io boolean FALSE
tape_asynch_io boolean TRUE
11:25:53 SYS@ prod>select event,TOTAL_WAITS,AVERAGE_WAIT from v$system_event
11:25:58 2 where upper(event) like 'DB FILE%';
EVENT TOTAL_WAITS AVERAGE_WAIT
---------------------------------------------------------------- ----------- ------------
db file sequential read 2036 .02
db file scattered read 844 .01
db file single write 27 .69
db file parallel write 38 1.69
2、用戶進行事務操作
11:24:02 SCOTT@ prod>conn scott/tiger
Connected.
11:26:19 SCOTT@ prod>begin
11:26:38 2 for i in 1..100000 loop
11:26:38 3 execute immediate 'insert into t1 values ('||i||')';
11:26:38 4 end loop;
11:26:38 5 end;
11:26:38 6 /
11:24:06 TOM@ prod>conn tom/tom
Connected.
11:26:47 TOM@ prod>begin
11:26:57 2 for i in 1..100000 loop
11:26:57 3 execute immediate 'insert into scott.t1 values ('||i||')' ;
11:26:57 4 end loop;
11:26:57 5 end;
11:26:57 6 /
11:22:41 SYS@ prod>select event,TOTAL_WAITS,AVERAGE_WAIT from v$system_event
2* where upper(event) like 'DB FILE%'
EVENT TOTAL_WAITS AVERAGE_WAIT
---------------------------------------------------------------- ----------- ------------
db file sequential read 3216 .02
db file scattered read 846 .01
db file single write 27 .69
db file parallel write 67 2.78
Elapsed: 00:00:00.02
3、解決方法
11:22:42 SYS@ prod>show parameter sync
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
disk_asynch_io boolean TRUE
tape_asynch_io boolean TRUE
11:22:43 SYS@ prod>select event,TOTAL_WAITS,AVERAGE_WAIT from v$system_event
2* where upper(event) like 'DB FILE%'
EVENT TOTAL_WAITS AVERAGE_WAIT
---------------------------------------------------------------- ----------- ------------
db file sequential read 11801 .05
db file scattered read 1920 .03
db file single write 54 .35
db file async I/O submit 266 7.78
db file parallel read 39 .19
'db file parallel write ' 等待事件消失 !免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。