设为首页  
联系我们  
加入收藏  
网页制作 冲浪宝典 图形图像 操作系统 软件教学 编程开发 认证考试 安全技术 站长专区 文学驿站 娱乐天地 游戏天地 办公软件
文章搜索
您的位置: 首页 >> 文章首页 >> 编程开发 >> 数据库开发 >> Statspack之十四-log file sync 等待事件
精品推荐
数据库开发点击TOP10
·MYSQL 新版出现 Client does not support authentication protocol requested by server; consider upgrading MySQL client解决办法
·生成助记码(取汉字的第一个字母)
·ORA-01034错误的解决办法
·ORACLE数据库管理员的职责
·将DW数据窗口导出为EXCEL文件的方法(整理)
·Oracle中分区表的使用
·SQL Server 2000+ MS WIN2003群集服务配置
·SQL中UNION 与 UNION ALL 的区别
·ORA-00257: archiver error. Connect internal only, until freed.
·Oracle备份与恢复案例
编程开发点击TOP10
·数字小键盘指法练习
·ASP.NET 程序中常用的三十三种代码
·用C语言编通讯录程序(初学者级别的)
·我写的Java学生成绩管理系统源代码
·CHK文件恢复工具
·Modem 常用AT指令集
·java笔试题
·异常java.sql.SQLException: Io exception:The Network Adapter could not establish connection
·单片机模拟I2C总线及24C02(I2C EEPROM)读写实例(源代码)
·C++经典电子书下载
精选专题

Statspack之十四-log file sync 等待事件

作者: 来源:网络文章 时间:2005-12-17 22:30:32


原文出处:

http://www.eygle.com/statspack/statspack14-LogFileSync.htm

当一个用户提交(commits)或者回滚(rollback),session的redo信息需要写出到redo logfile中.
用户进程将通知LGWR执行写出操作,LGWR完成任务以后会通知用户进程.
这个等待事件就是指用户进程等待LGWR的写完成通知.

对于回滚操作,该事件记录从用户发出rollback命令到回滚完成的时间.

如果该等待过多,可能说明LGWR的写出效率低下,或者系统提交过于频繁.
针对该问题,可以关注:
log file parallel write等待事件
user commits,user rollback等统计信息可以用于观察提交或回滚次数

解决方案:
1.提高LGWR性能
尽量使用快速磁盘,不要把redo log file存放在raid 5的磁盘上
2.使用批量提交
3.适当使用NOLOGGING/UNRECOVERABLE等选项

可以通过如下公式计算平均redo写大小:

avg.redo write size = (Redo block written/redo writes)*512 bytes

如果系统产生redo很多,而每次写的较少,一般说明LGWR被过于频繁的激活了.
可能导致过多的redo相关latch的竞争,而且Oracle可能无法有效的使用piggyback的功能.

我们从一个statspack中提取一些数据来研究一下这个问题.

1.主要信息

DB NameDB Id InstanceInst Num ReleaseOPS Host------------ ----------- ------------ -------- ----------- --- ------------DB1222010599oracle1 8.1.7.4.5NOsun Snap IdSnap TimeSessions ------- ------------------ -------- Begin Snap: 3473 13-Oct-04 13:43:00540End Snap: 3475 13-Oct-04 14:07:28540 Elapsed:24.47 (mins)Cache Sizes~~~~~~~~~~~db_block_buffers:102400 log_buffer:20971520db_block_size: 8192 shared_pool_size: 600MLoad Profile~~~~~~~~~~~~ Per Second Per Transaction--------------- ---------------Redo size: 28,458.112,852.03......

2.等待事件

 

Event WaitsTimeoutsTime (CS) (ms)/txn---------------------------- ------------ ---------- ----------- ------ ------log file sync 14,466 2 4,1503 1.0db file sequential read17,202 0 2,8692 1.2latch free 24,84113,489 2,0721 1.7 direct path write121 0 1,455 120 0.0db file parallel write1,314 0 1,38311 0.1log file sequential read1,540 0 630 0.1....log file switch completion1 0330 0.0refresh controlfile command23 010 0.0LGWR wait for redo copy 46 000 0.0....log file single write 4 000 0.0

我们看到,这里log file sync和db file parallel write等待同时出现了.
显然log file sync在等待db file parallel write的完成.

这里磁盘IO肯定存在了瓶颈,实际用户的redo和数据文件同时存放在Raid的磁盘上,存在性能问题.
需要调整.

3.统计信息

 

 StatisticTotalper Second per Trans--------------------------------- ---------------- ------------ ------------....redo blocks written 93,85363.9 6.4redo buffer allocation retries 1 0.0 0.0redo entries 135,83792.5 9.3redo log space requests1 0.0 0.0redo log space wait time 3 0.0 0.0redo ordering marks0 0.0 0.0redo size 41,776,50828,458.12,852.0redo synch time4,174 2.8 0.3redo synch writes14,198 9.7 1.0redo wastage4,769,2003,248.8325.6redo write time3,698 2.5 0.3redo writer latching time0 0.0 0.0redo writes14,572 9.9 1.0....sorts (disk) 4 0.0 0.0sorts (memory)179,856122.512.3sorts (rows)2,750,9801,874.0187.8....transaction rollbacks36 0.0 0.0transaction tables consistent rea 0 0.0 0.0transaction tables consistent rea 0 0.0 0.0user calls 1,390,718947.494.9user commits14,136 9.6 1.0user rollbacks512 0.4 0.0write clones created in backgroun 0 0.0 0.0write clones created in foregroun11 0.0 0.0 -------------------------------------------------------------
avg.redo write size = (Redo block written/redo writes)*512 bytes = ( 93,853 / 14,572 )*512= 3K



这个平均过小了,说明系统的提交过于频繁.

 

 Latch Sleep breakdown for DB: DPSHDBInstance: dpshdbSnaps: 3473 -3475-> ordered by misses descGet Spin &Latch NameRequestsMissesSleeps Sleeps 1->4-------------------------- -------------- ----------- ----------- ------------row cache objects12,257,850113,299 64 113235/64/0/0/0shared pool3,690,71560,27915,857 52484/588/6546/661/0library cache 4,912,46529,454 8,876 23823/2682/2 733/216/0cache buffers chains10,314,526 2,856 33 2823/33/0/0/0redo writing76,5509371 936/1/0/0/0session idle bit 2,871,9492251 224/1/0/0/0messages107,9501592 157/2/0/0/0session allocation 184,386 446 38/6/0/0/0checkpoint queue latch 96,58311 0/1/0/0/0 -------------------------------------------------------------

由于过渡频繁的提交,LGWR过度频繁的激活,我们看到这里出现了redo writing的latch竞争.

关于redo writing竞争你可以在steve的站点找到详细的介绍:
http://www.ixora.com.au/notes/lgwr_latching.htm


转引如下:

 

When LGWR wakes up, it first takes the redo writing latch to update the SGA variable that shows whether it is active. This prevents other Oracle processes from posting LGWR needlessly. LGWR then takes the redo allocation latch to determine how mUCh redo might be available to write (subject to the release of the redo copy latches). If none, it takes the redo writing latch again to record that it is no longer active, before starting another rdbms ipc message wait.
If there is redo to write, LGWR then inspects the latch recovery areas for the redo copy latches (without taking the latches) to determine whether there are any incomplete copies into the log buffer. For incomplete copies above the sync RBA, LGWR just defers the writing of that block and subsequent log buffer blocks. For incomplete copies below the sync RBA, LGWR sleeps on a LGWR wait for redo copy wait event, and is posted when the required copy latches have been released. The time taken by LGWR to take the redo writing and redo allocation latches and to wait for the redo copy latches is accumulated in the redo writer latching time statistic.

(Prior to release 8i, foreground processes held the redo copy latches more briefly because they did not retain them for the application of the change vectors. Therefore, LGWR would instead attempt to assure itself that there were no ongoing copies into the log buffer by taking all the redo copy latches.)

After each redo write has completed, LGWR takes the redo allocation latch again in order to update the SGA variable containing the base disk block for the log buffer. This effectively frees the log buffer blocks that have just been written, so that they may be reused.

 

 

本文作者:
eygle,Oracle技术关注者,来自中国最大的Oracle技术论坛itpub.
www.eygle.com是作者的个人站点.你可通过Guoqiang.Gai@gmail.com来联系作者.欢迎技术探讨交流以及链接交换.


原文出处:

http://www.eygle.com/statspack/statspack14-LogFileSync.htm



Statspack之十四-log file sync 等待事件 相关文章:
Statspack之十四-log file sync 等待事件 相关软件:
特别声明:本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。
转载请注明来源:http://www.xgdown.com