nologging跟redo size之间的关系分析 转贴
nologging和redo size之间的关系分析 转贴
nologging和redo size之间的关系分析
2011年01月29日 星期六 下午 12:41
试验环境:oracle 9204 on hp-ux
一、使用CTAS方式建表产生redo大小的分析
首先在noarchive模式下试验:
试验前:
SQL> select a.name, b.value from v$statname a, v$sesstat b where a.statistic#=b.statistic# and b.sid=9 and a.name = 'redo size';
NAME VALUE
redo size 600
SQL> create table t as select * from dba_objects;
试验后:
SQL>
NAME VALUE
redo差异:30960
2、更改数据库到归档模式,过程省略。。。
table采用默认方式建立:
试验前:
SQL> select a.name, b.value from v$statname a, v$sesstat b where a.statistic#=b.statistic# and b.sid=9 and a.name = 'redo size';
NAME VALUE
redo size 1472
SQL> create table t as select * from dba_objects;
试验后:
NAME VALUE
redo size 622448
redo差异:620976,差不多是非归档模式下的20倍
3、table采用nologging方式建立:
试验前:
SQL> select a.name, b.value from v$statname a, v$sesstat b where a.statistic#=b.statistic# and b.sid=9 and a.name = 'redo size';
NAME VALUE
redo size 622448
SQL> create table t nologging as select * from dba_objects;
试验后:
NAME VALUE
redo size 654880
redo差异:32432,和非归档模式下差不多
二、使用sqloader+direct产生redo大小的分析
首先在noarchive模式下试验:
试验前:
SQL> select name, value from v$sysstat where name='redo size';
NAME VALUE
redo size 131088
加载:sqlldr userid=dc/dc control=test.ctl
试验后:
NAME VALUE
redo size 164144
redo差异:33056
因为在非归档模式下,不管表是logging还是nologging对直接路径加载生成的redo都没有影响,故不测试表为nologging的情况
2、更改数据库到归档模式,过程省略。。。
table采用默认方式建立:
试验前:
SQL> select name, value from v$sysstat where name='redo size';
NAME VALUE
redo size 5990200
加载:sqlldr userid=dc/dc control=test.ctl
试验后:
NAME VALUE
redo size 10717152
redo差异:4726952,是非归档模式下的100多倍
3、table采用nologging方式建立:
试验前:
SQL> select name, value from v$sysstat where name='redo size';
NAME VALUE
redo size 10825792
加载:sqlldr userid=dc/dc control=test.ctl
试验后:
SQL>
NAME VALUE
redo size 10858848
redo差异:33056,和非归档模式一样
三、alter table move产生redo大小的分析
首先在noarchive模式下试验:
试验前:
SQL> select a.name, b.value from v$statname a, v$sesstat b where a.statistic#=b.statistic# and b.sid=9 and a.name = 'redo size';
NAME VALUE
redo size 600
SQL> alter table test move tablespace test;
试验后:
SQL>
NAME VALUE
---------------------------- ----------
redo size 38544
redo差异:37944
2、更改数据库到归档模式
table采用默认方式建立:
试验前:
SQL> select a.name, b.value from v$statname a, v$sesstat b where a.statistic#=b.statistic# and b.sid=9 and a.name = 'redo size';
redo size 2816
SQL> alter table test move tablespace test;
试验后:
SQL>
redo size 4767640
redo差异:4764824,是非归档模式下的100多倍
3、move语句换一个方式:
试验前:
SQL> select a.name, b.value from v$statname a, v$sesstat b where a.statistic#=b.statistic# and b.sid=9 and a.name = 'redo size';
redo size 9517280
SQL> alter table test move tablespace test nologging;
试验后:
SQL>
NAME VALUE
---------------------------- ----------
redo size 14266928
redo差异:4749648,可见nologging子句没起作用
(注:觉得这个有问题,所以又在10.2.0.2平台上做了一遍,生成的redo和非归档模式差不多,而且move后相关的表也变为nologging的了,而9i里仍为logging,大家可以在其他平台试验一下)
4、table采用nologging方式建立:
SQL> select a.name, b.value from v$statname a, v$sesstat b where a.statistic#=b.statistic# and b.sid=9 and a.name = 'redo size';
NAME VALUE
redo size 14269024
SQL> alter table test move tablespace test;;
试验后:
NAME VALUE
redo size 14308200
redo差异:39176,和非归档模式下差不多
四、create index产生redo大小的分析
1、首先在noarchive模式下试验:
使用普通create index语句:
试验前:
SQL> select a.name, b.value from v$statname a, v$sesstat b where a.statistic#=b.statistic# and b.sid=9 and a.name = 'redo size';
NAME VALUE
redo size 600
SQL> create index idx_test on test(id);
试验后:
SQL>
NAME VALUE
redo size 1862688
redo差异:1862088
使用create index nologging语句:
试验前:
SQL> select a.name, b.value from v$statname a, v$sesstat b where a.statistic#=b.statistic# and b.sid=9 and a.name = 'redo size';
NAME VALUE
redo size 3805536
SQL> create index idx_test on test(id) nologging;
试验后:
SQL> /
redo size 3835280
redo差异:29744
2、更改数据库到归档模式
使用普通create index语句:
试验前:
SQL> select a.name, b.value from v$statname a, v$sesstat b where a.statistic#=b.statistic# and b.sid=9 and a.name = 'redo size';
NAME VALUE
redo size 600
SQL> create index idx_test on test(id);
试验后:
NAME VALUE
redo size 1862736
redo差异:1862136
使用create index nologging语句:
试验前:
SQL> select a.name, b.value from v$statname a, v$sesstat b where a.statistic#=b.statistic# and b.sid=9 and a.name = 'redo size';
redo size 1874344
SQL> create index idx_test on test(id) nologging;
试验后:
NAME VALUE
redo size 1904152
redo差异:29808
由此可得出不管数据库在归档还是非归档模式,建立索引时只有使用nologging子句才能减少redo。
另做了个alter index rebuild的结果也一样,过程就略了。
五、update/delete产生redo大小的分析
数据库使用归档模式
表为logging:
试验前:
SQL> select a.name, b.value from v$statname a, v$sesstat b where a.statistic#=b.statistic# and b.sid=9 and a.name = 'redo size';
NAME VALUE
redo size 600
SQL> update test set id=id+1;
试验后:
NAME VALUE
redo size 27290584
redo差异:27289984
表为nologging:
试验前:
SQL> select a.name, b.value from v$statname a, v$sesstat b where a.statistic#=b.statistic# and b.sid=9 and a.name = 'redo size';
NAME VALUE
redo size 45688568
SQL> update test set id=id+1;
试验后:
NAME VALUE
redo size 72978632
redo差异:27290064,两者几乎一样
nologging和redo size之间的关系分析
2011年01月29日 星期六 下午 12:41
试验环境:oracle 9204 on hp-ux
一、使用CTAS方式建表产生redo大小的分析
首先在noarchive模式下试验:
试验前:
SQL> select a.name, b.value from v$statname a, v$sesstat b where a.statistic#=b.statistic# and b.sid=9 and a.name = 'redo size';
NAME VALUE
redo size 600
SQL> create table t as select * from dba_objects;
试验后:
SQL>
NAME VALUE
redo差异:30960
2、更改数据库到归档模式,过程省略。。。
table采用默认方式建立:
试验前:
SQL> select a.name, b.value from v$statname a, v$sesstat b where a.statistic#=b.statistic# and b.sid=9 and a.name = 'redo size';
NAME VALUE
redo size 1472
SQL> create table t as select * from dba_objects;
试验后:
NAME VALUE
redo size 622448
redo差异:620976,差不多是非归档模式下的20倍
3、table采用nologging方式建立:
试验前:
SQL> select a.name, b.value from v$statname a, v$sesstat b where a.statistic#=b.statistic# and b.sid=9 and a.name = 'redo size';
NAME VALUE
redo size 622448
SQL> create table t nologging as select * from dba_objects;
试验后:
NAME VALUE
redo size 654880
redo差异:32432,和非归档模式下差不多
二、使用sqloader+direct产生redo大小的分析
首先在noarchive模式下试验:
试验前:
SQL> select name, value from v$sysstat where name='redo size';
NAME VALUE
redo size 131088
加载:sqlldr userid=dc/dc control=test.ctl
试验后:
NAME VALUE
redo size 164144
redo差异:33056
因为在非归档模式下,不管表是logging还是nologging对直接路径加载生成的redo都没有影响,故不测试表为nologging的情况
2、更改数据库到归档模式,过程省略。。。
table采用默认方式建立:
试验前:
SQL> select name, value from v$sysstat where name='redo size';
NAME VALUE
redo size 5990200
加载:sqlldr userid=dc/dc control=test.ctl
试验后:
NAME VALUE
redo size 10717152
redo差异:4726952,是非归档模式下的100多倍
3、table采用nologging方式建立:
试验前:
SQL> select name, value from v$sysstat where name='redo size';
NAME VALUE
redo size 10825792
加载:sqlldr userid=dc/dc control=test.ctl
试验后:
SQL>
NAME VALUE
redo size 10858848
redo差异:33056,和非归档模式一样
三、alter table move产生redo大小的分析
首先在noarchive模式下试验:
试验前:
SQL> select a.name, b.value from v$statname a, v$sesstat b where a.statistic#=b.statistic# and b.sid=9 and a.name = 'redo size';
NAME VALUE
redo size 600
SQL> alter table test move tablespace test;
试验后:
SQL>
NAME VALUE
---------------------------- ----------
redo size 38544
redo差异:37944
2、更改数据库到归档模式
table采用默认方式建立:
试验前:
SQL> select a.name, b.value from v$statname a, v$sesstat b where a.statistic#=b.statistic# and b.sid=9 and a.name = 'redo size';
redo size 2816
SQL> alter table test move tablespace test;
试验后:
SQL>
redo size 4767640
redo差异:4764824,是非归档模式下的100多倍
3、move语句换一个方式:
试验前:
SQL> select a.name, b.value from v$statname a, v$sesstat b where a.statistic#=b.statistic# and b.sid=9 and a.name = 'redo size';
redo size 9517280
SQL> alter table test move tablespace test nologging;
试验后:
SQL>
NAME VALUE
---------------------------- ----------
redo size 14266928
redo差异:4749648,可见nologging子句没起作用
(注:觉得这个有问题,所以又在10.2.0.2平台上做了一遍,生成的redo和非归档模式差不多,而且move后相关的表也变为nologging的了,而9i里仍为logging,大家可以在其他平台试验一下)
4、table采用nologging方式建立:
SQL> select a.name, b.value from v$statname a, v$sesstat b where a.statistic#=b.statistic# and b.sid=9 and a.name = 'redo size';
NAME VALUE
redo size 14269024
SQL> alter table test move tablespace test;;
试验后:
NAME VALUE
redo size 14308200
redo差异:39176,和非归档模式下差不多
四、create index产生redo大小的分析
1、首先在noarchive模式下试验:
使用普通create index语句:
试验前:
SQL> select a.name, b.value from v$statname a, v$sesstat b where a.statistic#=b.statistic# and b.sid=9 and a.name = 'redo size';
NAME VALUE
redo size 600
SQL> create index idx_test on test(id);
试验后:
SQL>
NAME VALUE
redo size 1862688
redo差异:1862088
使用create index nologging语句:
试验前:
SQL> select a.name, b.value from v$statname a, v$sesstat b where a.statistic#=b.statistic# and b.sid=9 and a.name = 'redo size';
NAME VALUE
redo size 3805536
SQL> create index idx_test on test(id) nologging;
试验后:
SQL> /
redo size 3835280
redo差异:29744
2、更改数据库到归档模式
使用普通create index语句:
试验前:
SQL> select a.name, b.value from v$statname a, v$sesstat b where a.statistic#=b.statistic# and b.sid=9 and a.name = 'redo size';
NAME VALUE
redo size 600
SQL> create index idx_test on test(id);
试验后:
NAME VALUE
redo size 1862736
redo差异:1862136
使用create index nologging语句:
试验前:
SQL> select a.name, b.value from v$statname a, v$sesstat b where a.statistic#=b.statistic# and b.sid=9 and a.name = 'redo size';
redo size 1874344
SQL> create index idx_test on test(id) nologging;
试验后:
NAME VALUE
redo size 1904152
redo差异:29808
由此可得出不管数据库在归档还是非归档模式,建立索引时只有使用nologging子句才能减少redo。
另做了个alter index rebuild的结果也一样,过程就略了。
五、update/delete产生redo大小的分析
数据库使用归档模式
表为logging:
试验前:
SQL> select a.name, b.value from v$statname a, v$sesstat b where a.statistic#=b.statistic# and b.sid=9 and a.name = 'redo size';
NAME VALUE
redo size 600
SQL> update test set id=id+1;
试验后:
NAME VALUE
redo size 27290584
redo差异:27289984
表为nologging:
试验前:
SQL> select a.name, b.value from v$statname a, v$sesstat b where a.statistic#=b.statistic# and b.sid=9 and a.name = 'redo size';
NAME VALUE
redo size 45688568
SQL> update test set id=id+1;
试验后:
NAME VALUE
redo size 72978632
redo差异:27290064,两者几乎一样