[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#;

[20171113]修改表结构删除列相关问题4.txt的更多相关文章

  1. [20171113]修改表结构删除列相关问题3.txt

    [20171113]修改表结构删除列相关问题3.txt --//维护表结构删除字段一般都是先ALTER TABLE <table_name> SET UNUSED (<column_ ...

  2. [20171113]修改表结构删除列相关问题2.txt

    [20171113]修改表结构删除列相关问题2.txt --//测试看看修改表结构删除列产生的redo向量,对这些操作细节不了解,分析redo看看. 1.环境:SCOTT@book> @ &am ...

  3. [20171113]修改表结构删除列相关问题.txt

    [20171113]修改表结构删除列相关问题.txt --//维护表结构删除字段一般都是先ALTER TABLE <table_name> SET UNUSED (<column_n ...

  4. mysql在线修改表结构大数据表的风险与解决办法归纳

    整理这篇文章的缘由: 互联网应用会频繁加功能,修改需求.那么表结构也会经常修改,加字段,加索引.在线直接在生产环境的表中修改表结构,对用户使用网站是有影响. 以前我一直为这个问题头痛.当然那个时候不需 ...

  5. oracle 11g 通过在线重定义方式修改表结构

    今天因为要对一套数据库的数据抽取进行io优化,希望通过修改表结构将抽取io降下来,因为抽取只针对标签HAVE_FLAG为"0"的值进行抽取,抽取之后更新HAVE_FLAG为其他值, ...

  6. 必须会的SQL语句(二) 创建表、修改表结构、删除表

    1.创建数据库表 --使用哪个数据库,如果不写这一句是默认的数据库,也可以用鼠标选当前数据库 use testDB --创建表    Create Table tablename    (       ...

  7. SQL Server -- 回忆笔记(二):增删改查,修改表结构,约束,关键字使用,函数,多表联合查询

    SQL Server知识点回忆篇(二):增删改查,修改表结构,约束,关键字使用,函数,多表联合查询 1. insert 如果sql server设置的排序规则不是简体中文,必须在简体中文字符串前加N, ...

  8. (转)pt-online-schema-change在线修改表结构

    原文:http://www.ywnds.com/?p=4442 一.背景 MySQL大字段的DDL操作:加减字段.索引.修改字段属性等,在5.1之前都是非常耗时耗力的,特别是会对MySQL服务产生影响 ...

  9. SQL Server 修改表结构(转载)

    SQL Server 修改表结构 本文链接:https://blog.csdn.net/petezh/article/details/81744374 查看指定表结构 exec sp_help Rep ...

随机推荐

  1. 内存管理-slab[原理]

    前言 主要讲解原理,基于2.6.32版本内核源码.本文整体思路:先由简单内存模型逐渐演进到当下通用服务器面对的内存模型,讨论每一个内存模型下slab设计需要解决的问题. 历史简介 linux内核运行需 ...

  2. python函数练习——个人信息修改

    修改个人信息程序 在一个文件里存多个人的个人信息,如以下 1.输入用户名密码,正确后登录系统 ,打印 1. 修改个人信息 2. 打印个人信息 3. 修改密码 2.每个选项写一个方法 3.登录时输错3次 ...

  3. 高手速成android开源项目【View篇】

    主要介绍那些不错个性化的View,包括ListView.ActionBar.Menu.ViewPager.Gallery.GridView.ImageView.ProgressBar及其他如Dialo ...

  4. Android_Studio_Checkout_Github_Error"Cannot run program "git.exe":CreateProcess error = 2

    答案都在这了,如果你有下载过git而不是github,那么你可以指定git.exe给android studio 正如这样:

  5. 解决Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name) 中文显示乱码

    如果file.Name为中文则乱码.解决办法是方法1:response.setHeader("Content-Disposition", "attachment; fil ...

  6. 【JAVA】ThreadLocal源码分析

    ThreadLocal内部是用一张哈希表来存储: static class ThreadLocalMap { static class Entry extends WeakReference<T ...

  7. Python pandas学习总结

    本来打算学习pandas模块,并写一个博客记录一下自己的学习,但是不知道怎么了,最近好像有点急功近利,就想把别人的东西复制过来,当心沉下来,自己自觉地将原本写满的pandas学习笔记删除了,这次打算写 ...

  8. Java和Python分别实现直接选择排序

    1.基本思想 将指定排序位置与其他数组元素分别对比,如果满足条件就进行交换.个人理解其实就是每趟循环从数组里选一个最大的值(最小的值)放到数组最后(最前). 2.算法实现 这里以每趟循环从数组中选择一 ...

  9. memcached优化方案实例

    <?php //引入memcached require_once '../class/memcached.class.php'; //连接MySQL $link = mysqli_connect ...

  10. MyBatis从入门到放弃二:传参

    前言 我们在mapper.xml写sql,如果都是一个参数,则直接配置parameterType,那实际业务开发过程中多个参数如何处理呢? 从MyBatis API中发现selectOne和selec ...