在11.2.0.3版本中,Oracle 默认启用 _use_adaptive_log_file_sync 参数,使得 LGWR 进程写日志的方式能自动在 post/wait 和 polling 两种方式之间进行取舍,可能会导致比较严重的写日志等待(log file sync的平均单次等待时间较高),建议关闭此功能。
参考命令:alter system set "_use_adaptive_log_file_sync"=FALSE;
在11gr2以前写日志缓冲区到文件方式是通过Post/wait方式,在11gr2开始增加了Polling的方式,在11.2.0.3以前默认还是采用Post/wait方式,
11.2.0.3开始默认是两种方式自动切换。它是通过隐含参数_use_adaptive_log_file_sync进行设置,当值为true时开启自动切换模式。
Post/wait:用户会话被动等待LGWR通知redo写入到log file完毕,这种方式响应速度比较快。若cpu空闲时采用这种方式可以体验到更好的响应时间。
Polling:用户会话主动监测LGWR是否完成写入。这种方式比Post/wait方式响应速度慢,LGWR不直接把完成的消息通知到很多用户会话,可以节约CPU资源。若cpu繁忙时采用这种方式可以降低cpu资源的消耗。
SQL> select x.ksppinm name, y.ksppstvl value, x.ksppdesc describ
2 from sys.x$ksppi x, sys.x$ksppcv y
3 where x.inst_id = userenv ('Instance')
and y.inst_id = userenv ('Instance')
4 5 and x.indx = y.indx
6 and ( x.ksppinm = '_use_adaptive_log_file_sync');
NAME
--------------------------------------------------------------------------------
VALUE
--------------------------------------------------------------------------------
DESCRIB
--------------------------------------------------------------------------------
_use_adaptive_log_file_sync
TRUE
Adaptively switch between post/wait and polling
SQL> select name,value from v$sysstat where name like 'redo sync%';
NAME VALUE
---------------------------------------------------------------- ----------
redo synch time 12938
redo synch time (usec) 133596216
redo synch writes 72793
redo synch long waits 1734
redo synch poll writes 0
redo synch polls 0
6 rows selected.
SQL>