The Redo Log Buffer
LGWR只有1个进程,不像DBWn可以有多个。LGWR速度受限于ARCn和DBWn。
when LGWR writes?
- A user process commits a transaction
- Every three seconds
- when the redo log buffer is one-third full
- when a DBWn process writes modified buffers to disk, if the corresponding redo log
- data has not already been written to disk.
Adjust LOG_BUFFER, 大小设置:512K or 128k*cpu_count,choose the greater
show parameter cpu_count;
查询Redo Log Buffer
SQL> select * from v$sgastat where name='log_buffer';
POOL NAME BYTES
------------ -------------------------- ----------
log_buffer 5160960
Redo Log Buffer Inefficiency
产生日志太快,LGWR速度跟不上。
调优目标:始终有空余的redo log buffer可写;始终有空闲的redo log file可写。不要产生等待。
调优手段:通用:增加组数,增加每组的容量;其他手段:增加DBWn个数,增加ARCn个数。
在alert文件中,检查“CHECKPOINT NOT COMPLETE”信息。
诊断指标
- v$session_wait Log Buffer Space event (存在retries时会发生这个事件)
-
-
查询Log Buffer Space event事件SQL> select sid, event, seconds_in_wait, state from v$session_waitwhere event='log buffer space%';
-
- v$sysstat Redo Buffer Allocation Retries(总共有多少条记录), Redo Entries(redo log buffer没有空余空间再尝试)
因此调优目标就是:
- There should be no Log Buffer Space waits.
- Redo Entries/Redo Buffer Allocation Retries near 0
原因和调整措施
1. 磁盘争用导致redo log file无法及时写,确保redo log files放在独立的,速度快的磁盘上。
从v$system_event视图中,查询应log file switch completion event,该事件表明了由于log switch而导致的log file switch waits.
select event, total_waits, time_waited, average_wait
from v$system_event
where event like 'log file switch completion%';
措施:增加redo log files的大小
2. LGWR要写的下一组log file中对应的buffer cache中的脏数据还没有写入data file,由于DBWn写速度太慢或者要写的内容太多,LGWR必须等待DBWn进程。
从v$system_event视图中,查询Log File Switch (Checkpoint Incomplete) event。该事件表明了由于incomplete checkpoints而导致的log file switch waits.
select event, total_waits, time_waited, average_wait
from v$system_event
where event like 'log file switch (check%';
措施: 增加redo log的组数和大小,适量增加DBWn的个数
3. ARCn进程不够快阻止了LGWR写。
检查归档设备是否已经写满;增加redo log组;设置LOG_ARCHIVE_MAX_PROCESSES来增加归档进程数目。
从v$system_event中,查找Log File Switch (Archiving Needed) event, 该事件表明archiving issue导致了log file switch waits.
select event, total_waits, time_waited, average_wait
from v$system_event
where event like 'log file switch (arch%';
Reducing Redo Operations
ways to avoid logging bulk operations in the redo log:
- Direct Path loading without archiving不产生redo
- Direct Path loading with archiving use nologging mode
- Direct Load Insert can use Nologging mode
- Some SQL statements can use Nologgin mode.