1 等待事件说明
当用户执行完事务(insert插入数据)执行commit/rollbackup命令后,Oracle后台LGWR进程需要redo log buffer -> online redo log files,写入后返回Commit complete/Rollback complete.。这个过程就会形成Log File Sync等待事件。


Log File Parallel Write是LGWR进程开始执行到结束这个过程的等待事件。

2 模拟该等待事件
2.1 单次

查不到等待事件
2.2 多次
drop table sync;
create table sync (x int);
begin
for i in 1 .. 100000
loop
insert into sync values (i);
commit work write wait immediate;
end loop;
end;
/


drop table sync;
create table sync (x int);
begin
for i in 1 .. 100000
loop
insert into sync values (i);
commit;
end loop;
end;
/
commit_write、commit_logging、commit_wait
drop table baipx;
create table baipx as select * from dba_objects;
begin
for i in 1 .. 100
loop
insert into baipx select * from baipx;
commit;
end loop;
end;
/

2.3 别的等待事件
log file sequential read


log file parallel write


3 原因
数据库层面:
- 提交或者回滚次数过于频繁 -> 查看统计信息(统计user commits,user rollback次数)
- 日志缓冲区过大
- redo logfile过少
系统层面:
结合log file parallel write等待事件来判断
- I/O缓慢导致LGWR进程写日志慢 (log file sync ≈ log file parallel write)
- CPU使用率过高 (log file sync > log file parallel write)
4 解决方案
找到相应原因进行解决。
数据库层面:
- 提交或者回滚次数过于频繁 -> 批量提交
- 日志缓冲区过大
- redo logfile过少
系统层面:
- I/O缓慢导致LGWR进程写日志慢 -> 使用性能好的盘
- CPU使用率过高
5 学习链接
log file switch (日志切换)
log file sync( 日志文件同步)
Oracle log file sync 原理详解
频繁commit导致的log file sync的诊断
Oracle Log File Sync与LogFileParallelWrite:原因、诊断与解决方案
本文深入探讨了Oracle数据库中Log File Sync和LogFile Parallel Write两个等待事件,分析了它们产生的原因,如频繁提交、日志缓冲区过大或日志文件过少等,并提供了相应的诊断方法和解决方案,包括批量提交、调整日志文件配置和优化系统I/O及CPU使用情况。
678

被折叠的 条评论
为什么被折叠?



