如何计算一个insert语句产生的undo space大小

[复制链接]
查看11 | 回复9 | 2005-10-10 01:01:29 | 显示全部楼层 |阅读模式
oracle数据库对于insert一行到表里,在undo segment里只会记录这条语句的rowid就可以,下面是我测试的结果:
SQL> create table t7 (name char(2000));
Table created.
SQL> select * from v$rollstat;
USN LATCH EXTENTS RSSIZE WRITES XACTS GETS
WAITS
---------- ---------- ---------- ---------- ---------- ---------- ----------
---------- -
0 0 6 385024 17842 0 211
2
11 0 2 122880 [B]4618[/B] 0 46
0
12 0 2 122880 2072 0 34
0
13 0 2 122880 7724 0 46
0
SQL> insert into t7 values('llll');
1 row created.
SQL> select * from v$rollstat;
USN LATCH EXTENTS RSSIZE WRITES XACTS GETS
WAITS
---------- ---------- ---------- ---------- ---------- ---------- ----------
---------- -
0 0 6 385024 17842 0 212
2
11 0 2 122880 [B]4716[/B] 1 48
0
12 0 2 122880 2072 0 35
0
13 0 2 122880 7724 0 47
0
但是写到undo space的大小是98(4716 -4618),不知道这个什么意思?请各位大大帮忙解释下,谢谢!!
回复

使用道具 举报

千问 | 2005-10-10 01:01:29 | 显示全部楼层
不知是不是我没说清楚,还是其他原因,呵呵
回复

使用道具 举报

千问 | 2005-10-10 01:01:29 | 显示全部楼层
就是这个insert产生的undo是4716 -4618=98,还有什么?你自己已经说清楚了
回复

使用道具 举报

千问 | 2005-10-10 01:01:29 | 显示全部楼层
这个98代表的是bytes吗?
回复

使用道具 举报

千问 | 2005-10-10 01:01:29 | 显示全部楼层
最初由 tramplhg 发布
[B]这个98代表的是bytes吗? [/B]

According to documentation, yes. Oracle is notorious in sometimes not making a clear distinction between number of I/O's and number of blocks for the I/O.
You should always tell us your Oracle version. My test in 10.2.0.2.0 shows that the change in the statistic 'undo change vector size' is very close to the change in v$rollstat.writes after I insert a number into a very simple table. You can do the same test. But I don't know if pre-10g version has any statistic like this.
Yong Huang
回复

使用道具 举报

千问 | 2005-10-10 01:01:29 | 显示全部楼层
from oracle9i document:
WRITESNUMBERNumber of bytes written to the rollback segment
回复

使用道具 举报

千问 | 2005-10-10 01:01:29 | 显示全部楼层
最初由 Yong Huang 发布
[B]
According to documentation, yes. Oracle is notorious in sometimes not making a clear distinction between number of I/O's and number of blocks for the I/O.
You should always tell us your Oracle version. My test in 10.2.0.2.0 shows that the change in the statistic 'undo change vector size' is very close to the change in v$rollstat.writes after I insert a number into a very simple table. You can do the same test. But I don't know if pre-10g version has any statistic like this.
Yong Huang [/B]


Yong Huang,
我得oracle版本是9207, 在v$sysstat 我没有发现关于产生undo大小得参数, 也没有你上面提到得'undo change vector size'。
我现在感到这个98到底是怎么算出来得, 我测试过,对于insert语句不管你插入得row多大,都是98。
我知道rowid是18位得,那不应该是98啊!!!!
回复

使用道具 举报

千问 | 2005-10-10 01:01:29 | 显示全部楼层
最初由 tramplhg 发布
[B]

Yong Huang,
我得oracle版本是9207, 在v$sysstat 我没有发现关于产生undo大小得参数, 也没有你上面提到得'undo change vector size'。
我现在感到这个98到底是怎么算出来得, 我测试过,对于insert语句不管你插入得row多大,都是98。
我知道rowid是18位得,那不应该是98啊!!!! [/B]

Before 10g, you have to rely on v$transaction.used_ublk, which is number of undo blocks the transaction is using. The 10g statistic 'undo change vector size' is just a more accurate way to report undo for your session, and of course it persists after the transaction is finished (committed or rolled back). The conversion between these two is probably
v$transaction.used_ublk = ceil('undo change vector size' / db_block_size)
I don't have an answer as to how 98 bytes comes from your insert. We may be able to find it by doing research with some Metalink documents. Obviously Oracle has to do a lot of other work behind the scenes (recursive SQLs).
Yong Huang
回复

使用道具 举报

千问 | 2005-10-10 01:01:29 | 显示全部楼层
最初由 Yong Huang 发布
[B]
Before 10g, you have to rely on v$transaction.used_ublk, which is number of undo blocks the transaction is using. The 10g statistic 'undo change vector size' is just a more accurate way to report undo for your session, and of course it persists after the transaction is finished (committed or rolled back). The conversion between these two is probably
v$transaction.used_ublk = ceil('undo change vector size' / db_block_size)
I don't have an answer as to how 98 bytes comes from your insert. We may be able to find it by doing research with some Metalink documents. Obviously Oracle has to do a lot of other work behind the scenes (recursive SQLs).
Yong Huang [/B]


Yong Huang
谢谢,我也正在metalink上开了tar等待回复!
回复

使用道具 举报

千问 | 2005-10-10 01:01:29 | 显示全部楼层
最初由 tramplhg 发布
[B]

Yong Huang
谢谢,我也正在metalink上开了tar等待回复! [/B]

Did you get any feedback from your Tar?
Yong Huang
回复

使用道具 举报

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

本版积分规则