sys@ORCL> select EVENT,TOTAL_WAITS,TIME_WAITED,TIME_WAITED_MICRO 2 from v$system_event 3 where event like '%log file%';EVENT TOTAL_WAITS TIME_WAITED TIME_WAITED_MICRO------------------------------ ----------- ----------- -----------------log file sequential read 8 4 35571log file single write 8 1 9462log file parallel write 968 4672 46715069log file sync 300 3734 37336558
log file parallel write如果大於10ms就有可能I/O有問題
log file parallel write 跟提交木有關係,提交是 log file sync,不提交也會寫redo log
log file sync等待事件是使用者發出提交或復原聲明後,等待提交完成的事件,提交命令會去做日誌同步,也就是寫日誌緩衝到記錄檔
在提交命令未完成前,使用者將會看見此等待事件,注意,它專指因提交,復原而造成的寫緩衝到記錄檔的等待
當發生此等待事件時,有時也會伴隨log file parallel write
因為此等待事件將會寫日誌緩衝,如果日誌的I/O系統較為緩慢的話,這必將造成log file parallel write 等待
當發生log file sync等待後,判斷是否由於緩慢的日誌I/O造成的,可以查看兩個等待事件的等待時間
如果比較接近,就證明日誌I/O比較緩慢或重做日誌過多
這時,造成log file sync的原因是因為log file parallel write,可以參考解決log file parallel write的方法解決問題
如果log file sync的等待時間很高,而log file parallel write的等待時間並不高
這意味著log file sync的原因並不是緩慢的日誌I/O,而是應用程式過多的提交造成的
log file sync常常和log file parallel write一般同時關注,大致的發生過程如下:
① server process接到提交請求
② server process通知LGWR寫Redo entries到Redo log file
③ LGWR寫Redo到檔案
④ LGWR寫完通知server process
⑤ server process收到寫完成的通知,向使用者端發送提交完成
從步①開始,server process開始等待log file sync,到步⑤結束
步③、步④,LGWR等待log file parallel write
log file sync是按會話累計的,而log file parallel write不是
所以,如果log file parallel write慢,導致的放大效應很明顯,十個SP等一個LGWR進程寫磁碟,log file sync的等待時間就被放大了十倍
那麼,有時log file sync比log file parallel write大很大,便有兩個原因,一是CPU緊張,二是同時提交的進程多
如果10個進程同時提交,每個進程等0.1秒,加起來就一共等了1秒,而log file parallel write只會有一個進程等待,就是LGWR
這兩個等待事件屬於I/O範疇,可結合vmstat和iostat查看I/O狀況
OCP考題:
In your production database, the total waits and the time waited for log file parallel write are significantly high. While investigatingthe reason, you find that there are three redo log groups with two members in each group, and all redo log members are places on a single physical disk. What action would you take to minimize the waits?
A. Start the log writer slave processes B. Increase the number of redo log files C. Increase the size of the redo log buffer D. Place the redo log files on the different disks. E. Increase the number of log writer processes. Answer:D