楼主: liyongdong

REDO日志的基本结构

[复制链接]
论坛徽章:
62
2015中国数据库技术大会纪念徽章
日期:2015-04-24 16:04:24版主2段
日期:2012-05-15 15:24:112012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-01-04 11:49:54ITPUB十周年纪念徽章
日期:2011-11-01 16:19:41现任管理团队成员
日期:2011-05-07 01:45:08
11#
 楼主| 发表于 2005-12-27 11:22 | 只看该作者
相较于执行UPDATE、INSERT、DELETE处理,在执行CREATE、DROP处理时会对REDO执行大量写入的现象。

使用道具 举报

回复
论坛徽章:
62
2015中国数据库技术大会纪念徽章
日期:2015-04-24 16:04:24版主2段
日期:2012-05-15 15:24:112012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-01-04 11:49:54ITPUB十周年纪念徽章
日期:2011-11-01 16:19:41现任管理团队成员
日期:2011-05-07 01:45:08
12#
 楼主| 发表于 2005-12-27 11:23 | 只看该作者
这是因为CREATE(DROP)表的时候,会对多个数据字典进行变更。如果只是1个INSERT(DELETE)处理,那么只会产生一次REDO entry (record),但是执行CREATE处理的时候会发生69次(DROP的情况下会发生51次) entry。实际调查REDO.DUMP的内容就会发现69次entry中绝大部分都是针对数据字典产生的。
当ORACLE运行在NOLOGGING模式时,因为不会把 dictionary变更以外的部分纪录到日志中去,所以可以大幅减少对REDO日志进行写入的次数,从而提升REDO的

使用道具 举报

回复
论坛徽章:
62
2015中国数据库技术大会纪念徽章
日期:2015-04-24 16:04:24版主2段
日期:2012-05-15 15:24:112012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-01-04 11:49:54ITPUB十周年纪念徽章
日期:2011-11-01 16:19:41现任管理团队成员
日期:2011-05-07 01:45:08
13#
 楼主| 发表于 2005-12-27 11:26 | 只看该作者
性能。

使用道具 举报

回复
论坛徽章:
47
蒙奇·D·路飞
日期:2017-03-27 08:04:23马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11一汽
日期:2013-09-01 20:46:27复活蛋
日期:2013-03-13 07:55:232013年新春福章
日期:2013-02-25 14:51:24ITPUB 11周年纪念徽章
日期:2012-10-09 18:03:322012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:20
14#
发表于 2005-12-27 12:59 | 只看该作者
I'm afraid I have to clarify something you wrote. A server process *is* what Oracle articles sometimes call foreground process, as distinct from a background process (v$bgprocess). But you may already agree with this.

You seem to keep saying before image of a data block is written to log buffer (and eventually redo logfiles). That's not true. As I said, redo records only record changes, no before image, which is what rollback or undo does.

"在频繁执行Update操作的情况下,LGWR会满负荷运行" should be qualified to be "在频繁执行DML操作的情况下 *and* with frequent commits,..." Without commits, LGWR doesn't work that hard. It's true that without commits, server processes still write redo records into log buffer. But LGWR only works when log buffer is 1/3 full (the 3 second rule still applies but it's unrelated to frequent DMLs).

A change vector does not contain before image. It does have block DBA, as well as block version number and op code.

By "在编写程序的时候要集中transaction再进行处理", you mean commit only if absolutely necessary? That's good advice because you want to avoid too many log file sync waits, one common problem in OLTP databases. However, regardless how frequently you commit, the amount of redo is about the same and is dependent on your business logic.

Generally, update generates the most *undo*, insert the least, delete in the middle unless it's a long row. (But you can create cases this general rule doesn't apply.) It's an interesting question which one of the three generates the most or least *redo*. I think since the accompanied undo for these DMLs also generates redo, the total amount of redo follows the same order (i.e. update > delete > insert). Anyway, I don't follow your logic that "UPDATE、INSERT、DELETE对REDO日志文件写入的信息量并没有太大的差异" based on logfile block size being 512.

Yong Huang

使用道具 举报

回复
论坛徽章:
62
2015中国数据库技术大会纪念徽章
日期:2015-04-24 16:04:24版主2段
日期:2012-05-15 15:24:112012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-01-04 11:49:54ITPUB十周年纪念徽章
日期:2011-11-01 16:19:41现任管理团队成员
日期:2011-05-07 01:45:08
15#
 楼主| 发表于 2005-12-27 13:38 | 只看该作者
最初由 Yong Huang 发布
[B]I'm afraid I have to clarify something you wrote. A server process *is* what Oracle articles sometimes call foreground process, as distinct from a background process (v$bgprocess). But you may already agree with this.

You seem to keep saying before image of a data block is written to log buffer (and eventually redo logfiles). That's not true. As I said, redo records only record changes, no before image, which is what rollback or undo does.

"在频繁执行Update操作的情况下,LGWR会满负荷运行" should be qualified to be "在频繁执行DML操作的情况下 *and* with frequent commits,..." Without commits, LGWR doesn't work that hard. It's true that without commits, server processes still write redo records into log buffer. But LGWR only works when log buffer is 1/3 full (the 3 second rule still applies but it's unrelated to frequent DMLs).

A change vector does not contain before image. It does have block DBA, as well as block version number and op code.

By "在编写程序的时候要集中transaction再进行处理", you mean commit only if absolutely necessary? That's good advice because you want to avoid too many log file sync waits, one common problem in OLTP databases. However, regardless how frequently you commit, the amount of redo is about the same and is dependent on your business logic.

Generally, update generates the most *undo*, insert the least, delete in the middle unless it's a long row. (But you can create cases this general rule doesn't apply.) It's an interesting question which one of the three generates the most or least *redo*. I think since the accompanied undo for these DMLs also generates redo, the total amount of redo follows the same order (i.e. update > delete > insert). Anyway, I don't follow your logic that "UPDATE、INSERT、DELETE对REDO日志文件写入的信息量并没有太大的差异" based on logfile block size being 512.

Yong Huang [/B]


谢谢  Yong Huang   给我提出的问题与补充。
redo records only record changes, no before image,。是对的。我的错了。
对于UPDATE、INSERT、DELETE对REDO日志文件写入的信息量并没有太大的差异,是在通常的情况下。
如果是处理任务关联非常多的表,情况就会不同。

使用道具 举报

回复
论坛徽章:
0
16#
发表于 2005-12-28 10:29 | 只看该作者
学到很多知识,谢谢楼主讲解

使用道具 举报

回复
论坛徽章:
62
2015中国数据库技术大会纪念徽章
日期:2015-04-24 16:04:24版主2段
日期:2012-05-15 15:24:112012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-01-04 11:49:54ITPUB十周年纪念徽章
日期:2011-11-01 16:19:41现任管理团队成员
日期:2011-05-07 01:45:08
17#
 楼主| 发表于 2005-12-28 10:41 | 只看该作者
谢谢!,以后我还会补充。

使用道具 举报

回复
论坛徽章:
62
2015中国数据库技术大会纪念徽章
日期:2015-04-24 16:04:24版主2段
日期:2012-05-15 15:24:112012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-01-04 11:49:54ITPUB十周年纪念徽章
日期:2011-11-01 16:19:41现任管理团队成员
日期:2011-05-07 01:45:08
18#
 楼主| 发表于 2005-12-30 11:26 | 只看该作者
这次要说明和REDO有关的两个latch(latch是一种Oracle低级结构,用于保护内存资源,是一种内部生命周期很短的lock):REDO allocation latch和REDO copy latch的功能。

使用道具 举报

回复
论坛徽章:
62
2015中国数据库技术大会纪念徽章
日期:2015-04-24 16:04:24版主2段
日期:2012-05-15 15:24:112012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-01-04 11:49:54ITPUB十周年纪念徽章
日期:2011-11-01 16:19:41现任管理团队成员
日期:2011-05-07 01:45:08
19#
 楼主| 发表于 2005-12-30 11:28 | 只看该作者
把REDO信息写入到REDO日志缓冲时,Oracle必须取得REDO allocation latch和REDO copy latch这两个latch。
            REDO allocation(分配) latch:在REDO日志缓冲内,分配空间给要存入的REDO entry时所需的latch。
            REDO copy latch:当REDO entry太大,无法以REDO allocation latch执行copy时,REDO copy latch会代替REDO allocation latch执行copy。

使用道具 举报

回复
论坛徽章:
62
2015中国数据库技术大会纪念徽章
日期:2015-04-24 16:04:24版主2段
日期:2012-05-15 15:24:112012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-01-04 11:49:54ITPUB十周年纪念徽章
日期:2011-11-01 16:19:41现任管理团队成员
日期:2011-05-07 01:45:08
20#
 楼主| 发表于 2005-12-30 11:29 | 只看该作者
这两个latch的功能和作用请参考下图的说明。图中提到REDO entry的大小,主要取决于初始设定参数LOG_SMALL_ENTRY_MAX_SIZE。

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表