[20171113]修改表结构删除列相关问题4.txt
--//连续写了3篇修改表结构删除列的相关问题,链接如下:
http://blog.itpub.net/267265/viewspace-2147158/
http://blog.itpub.net/267265/viewspace-2147163/
http://blog.itpub.net/267265/viewspace-2147196/
--//从redo记录日志内容看,日志仅仅记录偏移位置 (piece relative column number),这样日志量还是相对较小,而且与删除字段的位置无关.
--//参考链接:
http://blog.itpub.net/267265/viewspace-2147163/
--//摘取其中1段,注意看下划线部分:
REDO RECORD - Thread:1 RBA: 0x000317.0000009c.0084 LEN: 0x017c VLD: 0x01
SCN: 0x0003.176a162e SUBSCN: 1 11/13/2017 10:13:57
CHANGE #1 TYP:0 CLS:35 AFN:3 DBA:0x00c00110 OBJ:4294967295 SCN:0x0003.176a1592 SEQ:1 OP:5.2 ENC:0 RBL:0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ktudh redo: slt: 0x0009 sqn: 0x0000532a flg: 0x0012 siz: 132 fbi: 0
uba: 0x00c1cd3c.10c6.10 pxid: 0x0000.000.00000000
CHANGE #2 TYP:0 CLS:36 AFN:3 DBA:0x00c1cd3c OBJ:4294967295 SCN:0x0003.176a1591 SEQ:1 OP:5.1 ENC:0 RBL:0
ktudb redo: siz: 132 spc: 3916 flg: 0x0012 seq: 0x10c6 rec: 0x10
xid: 0x000a.009.0000532a
ktubl redo: slt: 9 rci: 0 opc: 11.1 [objn: 90617 objd: 90617 tsn: 7]
Undo type: Regular undo Begin trans Last buffer split: No
Temp Object: No
Tablespace Undo: No
0x00000000 prev ctl uba: 0x00c1cd3c.10c6.0f
prev ctl max cmt scn: 0x0003.176a1392 prev tx cmt scn: 0x0003.176a1396
txn start scn: 0xffff.ffffffff logon user: 83 prev brb: 12700985 prev bcl: 0 BuExt idx: 0 flg2: 0
KDO undo record:
KTB Redo
op: 0x03 ver: 0x01
compat bit: 4 (post-11) padding: 1
op: Z
KDO Op code: DSC row dependencies Disabled
xtype: XA flags: 0x00000000 bdba: 0x01800081 hdba: 0x01800080
itli: 2 ispac: 0 maxfr: 4863
tabn: 0 slot: 0(0x0)
piece relative column number: 1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CHANGE #3 TYP:2 CLS:1 AFN:6 DBA:0x01800081 OBJ:90617 SCN:0x0003.176a14f9 SEQ:5 OP:11.14 ENC:0 RBL:0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
KTB Redo
op: 0x11 ver: 0x01
compat bit: 4 (post-11) padding: 1
op: F xid: 0x000a.009.0000532a uba: 0x00c1cd3c.10c6.10
Block cleanout record, scn: 0x0003.176a162e ver: 0x01 opt: 0x02, entries follow...
itli: 1 flg: 2 scn: 0x0003.176a14f9
KDO Op code: DSC row dependencies Disabled
xtype: XA flags: 0x00000000 bdba: 0x01800081 hdba: 0x01800080
itli: 2 ispac: 0 maxfr: 4863
tabn: 0 slot: 0(0x0)
piece relative column number: 1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--//还是通过了例子来说明:
0.环境:
SCOTT@book> @ &r/ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
--//建立测试脚本:
$ cat test1.sql
column name format a54
alter table t1 SET UNUSED (v1,v2,v3);
@ &r/viewredo
set timing on
ALTER TABLE t1 DROP UNUSED COLUMNS ;
set timing off
@ &r/viewredo
1.测试1:
--//drop table t1 purge;
create table t1 (id number,v0 varchar2(50),v1 varchar2(10),v2 varchar2(10),v3 varchar2(10));
insert into t1 select rownum,lpad('a',50,'a'),lpad('b',10,'b'),lpad('c',10,'c'),lpad('d',10,'d') from xmltable('1 to 1000000');
commit;
--//运行test1.sql:
SCOTT@book> @ test1.sql
Table altered.
NAME STATISTIC# VALUE
------------------------------------------------------ ---------- ----------
user commits 6 1
redo size 194 8124
redo wastage 199 0
data blocks consistent reads - undo records applied 326 0
Table altered.
Elapsed: 00:00:41.41
NAME STATISTIC# VALUE
------------------------------------------------------ ---------- ----------
user commits 6 2
redo size 194 687554932
redo wastage 199 0
data blocks consistent reads - undo records applied 326 0
--//redo=687554932-8124=687546808
2.测试2:
--//drop table t1 purge;
create table t1 (id number,v1 varchar2(10),v0 varchar2(50),v2 varchar2(10),v3 varchar2(10));
insert into t1 select rownum,lpad('a',10,'a'),lpad('b',50,'b'),lpad('c',10,'c'),lpad('d',10,'d') from xmltable('1 to 1000000');
commit;
--//运行test1.sql:
SCOTT@book> @ test1.sql
Table altered.
NAME STATISTIC# VALUE
------------------------------------------------------ ---------- ----------
user commits 6 1
redo size 194 8736
redo wastage 199 0
data blocks consistent reads - undo records applied 326 0
Table altered.
Elapsed: 00:00:40.31
NAME STATISTIC# VALUE
------------------------------------------------------ ---------- ----------
user commits 6 2
redo size 194 687540264
redo wastage 199 0
data blocks consistent reads - undo records applied 326 0
--//redo=687540264-8736=687531528.
3.测试3:
--//drop table t1 purge;
create table t1 (id number,v1 varchar2(10),v2 varchar2(10),v0 varchar2(50),v3 varchar2(10));
insert into t1 select rownum,lpad('a',10,'a'),lpad('b',10,'b'),lpad('c',50,'c'),lpad('d',10,'d') from xmltable('1 to 1000000');
commit;
--//运行test1.sql:
SCOTT@book> @ test1.sql
Table altered.
NAME STATISTIC# VALUE
------------------------------------------------------ ---------- ----------
user commits 6 1
redo size 194 8736
redo wastage 199 0
data blocks consistent reads - undo records applied 326 0
Table altered.
Elapsed: 00:00:41.57
NAME STATISTIC# VALUE
------------------------------------------------------ ---------- ----------
user commits 6 2
redo size 194 687620720
redo wastage 199 0
data blocks consistent reads - undo records applied 326 0
--//redo = 687620720-8736=687611984
4.测试4:
--//drop table t1 purge;
create table t1 (id number,v1 varchar2(10),v2 varchar2(10),v3 varchar2(10),v0 varchar2(50));
insert into t1 select rownum,lpad('a',10,'a'),lpad('b',10,'b'),lpad('c',10,'c'),lpad('d',50,'d') from xmltable('1 to 1000000');
commit;
--//运行test1.sql:
SCOTT@book> @ test1.sql
Table altered.
NAME STATISTIC# VALUE
------------------------------------------------------ ---------- ----------
user commits 6 1
redo size 194 8852
redo wastage 199 0
data blocks consistent reads - undo records applied 326 0
Table altered.
Elapsed: 00:00:40.99
NAME STATISTIC# VALUE
------------------------------------------------------ ---------- ----------
user commits 6 2
redo size 194 687650544
redo wastage 199 0
data blocks consistent reads - undo records applied 326 0
--//redo = 687650544 - 8852=687641692
5.分析:
--//删除v1,v2,v2列. v0列在测试中处在表的位置依次变化.而oracle的改变向量每次操作一个字段,因为日志中仅仅piece relative column number.
--//大小相对稳定,这样操作日志量大小不存在变化,而且相差很小.
--------------------------
v0出现位置 redo量 时间
---------------------------
2 687546808 41.41
3 687531528 40.31
4 687611984 41.57
5 687641692 40.99
--------------------------
--// 可以看出redo与时间消耗基本差不多.
6.总结:
--1.删除列不存在相关性.不是越靠前或者后面记录很大,而导致事务发生变化.
--2.感觉采用ctas或者采用在线表重定义也许更好.业务停顿可能更小.事务量还是偏大.
7.附上viewredo.sql脚本:
SELECT b.NAME, a.statistic#, a.VALUE
FROM v$mystat a, v$statname b
WHERE b.NAME IN ('redo size', 'redo wastage','user commits','data blocks consistent reads - undo records applied') AND a.statistic# = b.statistic#;