log file sync 和 log file parallel write等待事件的区别和联系

log file parallel write 和log file sync这两个等待事件关系密切,很多人对这两个等待事件有一些误解,我们先来看看Oracle官方文档的解释:

log file parallel write
Writing redo records to the redo log files from the log buffer.

Wait Time: Time it takes for the I/Os to complete. Even though redo records are written in parallel, the parallel write is not complete
until the last I/O is on disk.

log file sync
When a user session commits, the session’s redo information must be flushed to the redo logfile. The user session will
post the LGWR to write the log buffer to the redo log file. When the LGWR has finished writing, it will post the user session.

Wait Time: The wait time includes the writing of the log buffer and the post.

这两个等待事件的关系可以用下面这个图说明:
在这里插入图片描述
这两者之间的关系是:

  • log file sync 是前端等待事件,是从用户进程角度看的。
  • log file parallel write 是后端等待事件 ,是从LGWR进程角度看的。
  • log file sync中包含log file parallel write 。

第一个误区,很多人以为log file sync 这个等待事件反映了写redo的效率,实际上这个事件和cpu的性能很有关系,Kevin Closson有一篇精彩的论文来说明这个问题,虽然是十几年前写的,但仍然很有借鉴价值。他在这篇论文里面举例一个noise process占用了大量的cpu资源,造成log file sync 性能下降,有兴趣的同学可以看看这篇论文。
第二个误区,很多人以为这两个 log file sync减去log file parallel write就是cpu的时间,我在网上看到了太多这样的论断,其实我们仔细看看oracle官方文档的定义,log file sync是要从写log buffer算起的,其实oracle用的是group commit 来提高写redo的效率,也叫piggyback commit,这个不能由用户设置,如果log file parallel write效率低的适合有很多时间是用于等待的,特别是12C之前的版本,只有一个LGWR进程,等待的时间长不能算CPU效率低,实际还是写redo效率低造成的!我自己的一个测试案例是log file parallel write低到10ms时,log file parallel write下降到53ms。

猜你喜欢

转载自blog.csdn.net/weixin_43424368/article/details/108325427