Tuning the Redo Log Buffer by Jeff Hunter, Sr. Database Administrator
How does one tune the Redo Log Buffer? Submitted by admin on Sun, 2005-10-16 03:50.
The size of the Redo Log Buffer is determined by the LOG_BUFFER parameter in your SPFILE/INIT.ORA file. The default setting is normally 512 KB or (128 KB * CPU_COUNT), whichever is greater. This is a static parameter and its size cannot be modified after instance startup.
SQL> show parameters log_buffer
NAME
TYPE
value
------------------------------------ ----------- -----------------------------log_buffer
integer
262144
When a transaction is committed, info in the redo log buffer is written to a Redo Log File. In addition to this, the following conditions will trigger LGWR to write the contents of the log buffer to disk:
o o o
Whenever the log buffer is MIN(1/3 full, 1 MB) full; or Every 3 seconds; or When a DBWn process writes modified buffers to disk (checkpoint).
Larger LOG_BUFFER values reduce log file I/O, but may increase the time OLTP users have to wait for write operations to complete. In general, values between the default and 1 to 3MB are optimal. However, you may want to make it bigger to accommodate bulk data loading, or to accommodate a system with fast CPUs and slow disks. Nevertheless, if you set this parameter to a value beyond 10M, you should think twice about what you are doing.
SQL> SELECT name, value 2 3 4
FROM SYS.v_$sysstat WHERE NAME in ('redo buffer allocation retries', 'redo log space wait time');
NAME
value
---------------------------------------------------------------- ---------redo buffer allocation retries
3
redo log space wait time
0
Statistic "REDO BUFFER ALLOCATION RETRIES" shows the number of times a user process waited for space in the redo log buffer. This value is cumulative, so monitor it over a period of time while your application is running. If this value is continuously increasing, consider increasing your LOG_BUFFER (but only if you do not see checkpointing and archiving problems). "REDO LOG SPACE WAIT TIME" shows cumulative time (in 10s of milliseconds) waited by all processes waiting for space in the log buffer. If this value is low, your log buffer size is most likely adequate.
All changes (insert, update or delete) made to an Oracle data block will be contained in the Oracle redo log buffer. The redo log buffer gives the Oracle database the ability to recover from a media failure. If the redo buffers are not large enough, the Oracle log-writer process waits for space to become available. This wait time becomes wait time for the end user. The size of the redo log buffer is defined in the init.ora file using the 'LOG_BUFFER' parameter. The script below can be used to monitor if the log-writer process is waiting for redo log buffers. The time being reported is in 1/100's of a second SELECT SUM(value) "Redo Buffer Waits" FROM v$sysstat WHERE name = 'redo log space wait time';
LGWR writes redo entries from the redo log buffer to a redo log file. Once LGWR copies the entries to the redo log file the user process can over write these entries. The statistic 'redo log space requests' reflects the number of times a user process waits for space in the redo log buffer. Use the script below to monitor the number of times a user process had to wait for space within the redo log buffer. SELECT SUM(value) "Redo Buffer Waits" FROM v$sysstat WHERE name = 'redo log space requests';
Here are some tips in sizing the redo logs: • •
The value of "redo log space requests" should be near 0. Size your redo appropriately. The recommendation is to have the redo log switch every 15-30 minutes.
Finally, the following script can be used to view various statistics on your redo log buffer and files. COLUMN COLUMN SELECT FROM WHERE AND
value FORMAT 999,999,999,990 name FORMAT a31 a.name,b.value v$statname a,v$sysstat b a.statistic# = b.statistic# a.name like '%redo%';
NAME VALUE ------------------------------- ---------------redo synch writes 4,940,014 redo synch time 4,299,767 redo entries 203,212,938 redo size 47,844,123,778 redo entries linearized 0 redo buffer allocation retries 2,822 redo small copies 1,853,067 redo wastage 1,051,015,930 redo writer latching time 10,898 redo writes 5,382,902 redo blocks written 98,714,473 redo write time 5,216,053 redo log space requests 601
redo log space wait time redo log switch interrupts redo ordering marks
25,567 0 0
To change the redo log buffer size use this statement; alter system set log_buffer = XXXXX scope=spfile;
size in bytes and restart the database.
LOG_BUFFER Check the statistic redo buffer allocation retries in the V$SYSSTAT view. If this value is high relative to redo blocks written, try to increase the LOG_BUFFER size. A common LOG_BUFFER size for a system generating numerous logs is 3 MB to 5 MB. If the number of retries is still high after increasing LOG_BUFFER size, a problem might exist with the disk on which the log files reside. In that case, tune the I/O subsystem to increase the I/O rates for redo. One way of doing this is to use fine-grained striping across multiple disks. For example, use a stripe size of 16 KB. A simpler approach is to isolate redo logs on their own disk.