[20181116]18c DML 日志优化.txt
[20181116]18c DML 日志优化.txt
1.环境:
xxxxxxxx> select banner_full from v$version;
BANNER_FULL
-----------------------------------------------------------------------------
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.3.0.0.0
2.建立测试脚本:
xxxxxxxx> create table t as select rownum id ,lpad('y',200,'y') v1,lpad('z',100,'z') v2 from dual connect by level<=100;
Table created.
xxxxxxxx> select dump('x',16),dump('y',16),dump('z',16) from dual ;
DUMP('X',16) DUMP('Y',16) DUMP('Z',16)
-------------------------------- -------------------------------- --------------------------------
Typ=96 Len=1: 78 Typ=96 Len=1: 79 Typ=96 Len=1: 7a
xxxxxxxx> @ viewsess redo%size
NAME STATISTIC# VALUE SID
---------------------------------- ---------- -------------- ----------
redo size 293 684 258
redo size for lost write detection 295 0 258
redo size for direct writes 296 0 258
redo write size count ( 4KB) 321 0 258
redo write size count ( 8KB) 322 0 258
redo write size count ( 16KB) 323 0 258
redo write size count ( 32KB) 324 0 258
redo write size count ( 64KB) 325 0 258
redo write size count ( 128KB) 326 0 258
redo write size count ( 256KB) 327 0 258
redo write size count ( 512KB) 328 0 258
redo write size count (1024KB) 329 0 258
redo write size count (inf) 330 0 258
IMU Redo allocation size 736 0 258
14 rows selected.
--//建立测试脚本a.txt
column member new_value v_member
column member noprint
set numw 12
alter system switch logfile ;
--//alter system archive log current;
--//12c以上不允许在pluggable database执行这条命令.注这个库没有打开归档,alter system archive log current;会报错.
--//采用alter system switch logfile ;.
SELECT member FROM v$log a, v$logfile b WHERE a.group#(+) = b.group# and a.STATUS='CURRENT' and rownum=1;
column curr1 new_value v_curr1
select current_scn curr1 from v$database;
--//以下操作DML内容:
update t set v1=lpad('y',200,'y') ,v2=lpad('z',100,'z');
commit ;
exec dbms_session.sleep(3);
column curr2 new_value v_curr2
select current_scn curr2 from v$database;
prompt exec DBMS_LOGMNR.START_LOGMNR(STARTSCN => &&v_curr1 ,ENDSCN => &&v_curr2 ,OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG + DBMS_LOGMNR.CONTINUOUS_MINE);
prompt alter system dump logfile '&&v_member' scn min &&v_curr1 scn max &&v_curr2;
alter system dump logfile '&&v_member' scn min &&v_curr1 scn max &&v_curr2;
--//执行脚本a.txt:
xxxxxxxx> @ a.txt
System altered.
CURR1
------------
1336662128
100 rows updated.
Commit complete.
PL/SQL procedure successfully completed.
CURR2
------------
1336662131
exec DBMS_LOGMNR.START_LOGMNR(STARTSCN => 1336662128 ,ENDSCN => 1336662131 ,OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG + DBMS_LOGMNR.CONTINUOUS_MINE)
alter system dump logfile '+DATA/ORCLCDB/ONLINELOG/group_2.264.985030477' scn min 1336662128 scn max 1336662131
System altered.
xxxxxxxx> @ viewsess redo%size
NAME STATISTIC# VALUE SID
---------------------------------- ---------- -------------- ------------
redo size 293 23692 258
redo size for lost write detection 295 0 258
redo size for direct writes 296 0 258
redo write size count ( 4KB) 321 0 258
redo write size count ( 8KB) 322 0 258
redo write size count ( 16KB) 323 0 258
redo write size count ( 32KB) 324 0 258
redo write size count ( 64KB) 325 0 258
redo write size count ( 128KB) 326 0 258
redo write size count ( 256KB) 327 0 258
redo write size count ( 512KB) 328 0 258
redo write size count (1024KB) 329 0 258
redo write size count (inf) 330 0 258
IMU Redo allocation size 736 49012 258
14 rows selected.
--//日志大小 23692-648 = 23044 ,大约22K.
--//如果你查询转储文件,你可以发现一个奇特的信息,你根本找不到yyyy,zzzz相关的字符串信息.
--//也就是如果dml字段前后两者一样,日志根本没有记录.
3.修改dml语句重复测试:
$ cat a.txt
..
update t set v1=lpad('z',200,'z') ,v2=lpad('y',100,'y');
commit ;
...
--//执行a.txt
xxxxxxxx> @ viewsess redo%size
NAME STATISTIC# VALUE SID
---------------------------------- ---------- -------------- ----------
redo size 293 684 258
redo size for lost write detection 295 0 258
redo size for direct writes 296 0 258
redo write size count ( 4KB) 321 0 258
redo write size count ( 8KB) 322 0 258
redo write size count ( 16KB) 323 0 258
redo write size count ( 32KB) 324 0 258
redo write size count ( 64KB) 325 0 258
redo write size count ( 128KB) 326 0 258
redo write size count ( 256KB) 327 0 258
redo write size count ( 512KB) 328 0 258
redo write size count (1024KB) 329 0 258
redo write size count (inf) 330 0 258
IMU Redo allocation size 736 0 258
14 rows selected.
xxxxxxxx> @ a.txt
System altered.
CURR1
------------
1336662429
100 rows updated.
Commit complete.
PL/SQL procedure successfully completed.
CURR2
------------
1336662432
exec DBMS_LOGMNR.START_LOGMNR(STARTSCN => 1336662429 ,ENDSCN => 1336662432 ,OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG + DBMS_LOGMNR.CONTINUOUS_MINE)
alter system dump logfile '+DATA/ORCLCDB/ONLINELOG/group_3.262.985030477' scn min 1336662429 scn max 1336662432
System altered.
xxxxxxxx> @ viewsess redo%size
NAME STATISTIC# VALUE SID
---------------------------------- ---------- -------------- ------------
redo size 293 73948 258
redo size for lost write detection 295 0 258
redo size for direct writes 296 0 258
redo write size count ( 4KB) 321 0 258
redo write size count ( 8KB) 322 0 258
redo write size count ( 16KB) 323 0 258
redo write size count ( 32KB) 324 0 258
redo write size count ( 64KB) 325 0 258
redo write size count ( 128KB) 326 0 258
redo write size count ( 256KB) 327 0 258
redo write size count ( 512KB) 328 0 258
redo write size count (1024KB) 329 0 258
redo write size count (inf) 330 0 258
IMU Redo allocation size 736 36236 258
14 rows selected.
--//日志大小73948-648 = 73300,至少72K,比原来增加不少.
--//你可以看到如下:
REDO RECORD - Thread:1 RBA: 0x0008b3.0000002c.0134 LEN: 0x00e0 VLD: 0x01 CON_UID: 1
SCN: 0x000000004fabd870 SUBSCN: 2 11/16/2018 10:30:36
CHANGE #1 CON_ID:1 TYP:0 CLS:24 AFN:4 DBA:0x010008de OBJ:4294967295 SCN:0x000000004fabd870 SEQ:96 OP:5.1 ENC:0 RBL:0 FLG:0x0000
ktudb redo: siz: 68 spc: 866 flg: 0x0022 seq: 0x0ba1 rec: 0x69
xid: 0x0004.004.00002086
ktubu redo: slt: 4 rci: 104 opc: 11.1 objn: 104890 objd: 104890 tsn: 0
Undo type: Regular undo Undo type: Last buffer split: No
Tablespace Undo: No
0x00000000
KDO undo record:
KTB Redo
op: 0x02 ver: 0x01
compat bit: 4 (post-11) padding: 1
op: C uba: 0x010008de.0ba1.68
KDO Op code: LKR row dependencies Disabled
ktudb redo: siz: 68 spc: 656 flg: 0x0022 seq: 0x0ba1 rec: 0x6c
op: F xid: 0x0006.00d.00002131 uba: 0x010000c8.0b0c.01
Block cleanout record, scn: 0x000000004fabd99d ver: 0x01 opt: 0x02 bigscn: Y compact: Y spare: 00000000, entries follow...
itli: 3 flg: (opt=2 whr=1) scn: 0x000000004fabd871
Array Update of 20 rows:
tabn: 0 slot: 0(0x0) flag: 0x2c lock: 1 ckix: 0
ncol: 3 nnew: 2 size: 0
KDO Op code: 21 row dependencies Disabled
xtype: XAxtype KDO_KDOM2 flags: 0x00000080 bdba: 0x0041af39 hdba: 0x0041af38
itli: 1 ispac: 0 maxfr: 4863
vect = 3
col 1: [200]
7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a
7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a
7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a
7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a
7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a
7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a
7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a
7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a 7a
col 2: [100]
79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79
79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79
79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79
79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79
tabn: 0 slot: 1(0x1) flag: 0x2c lock: 1 ckix: 0
4.修改dml语句重复测试:
$ cat a.txt
..
update t set v1=lpad('z',200,'z') ,v2=lpad('x',100,'x');
commit ;
...
--//v1字段修改前后一样,v2字段前后不同,开始是lpad('y',100,'y')后面变成lpad('x',100,'x').
xxxxxxxx> @ viewsess redo%size
NAME STATISTIC# VALUE SID
----------- ---------- -------------- ----------
redo size 293 684 258
....
xxxxxxxx> @ a.txt
System altered.
CURR1
------------
1336662656
100 rows updated.
Commit complete.
PL/SQL procedure successfully completed.
CURR2
------------
1336662659
exec DBMS_LOGMNR.START_LOGMNR(STARTSCN => 1336662656 ,ENDSCN => 1336662659 ,OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG + DBMS_LOGMNR.CONTINUOUS_MINE)
alter system dump logfile '+DATA/ORCLCDB/ONLINELOG/group_1.265.985030477' scn min 1336662656 scn max 1336662659
System altered.
xxxxxxxx> @ viewsess redo%size
NAME STATISTIC# VALUE SID
--------- ---------- -------------- ------------
redo size 293 48340 258
....
--//日志大小48340-648 = 47692,47K上下.
--//检查跟踪文件你可以发现:
REDO RECORD - Thread:1 RBA: 0x0008b5.0000005f.0040 LEN: 0x01d0 VLD: 0x01 CON_UID: 1
SCN: 0x000000004fabda80 SUBSCN:1176 11/16/2018 10:44:53
CHANGE #1 CON_ID:1 TYP:0 CLS:18 AFN:4 DBA:0x01000087 OBJ:4294967295 SCN:0x000000004fabda80 SEQ:27 OP:5.1 ENC:0 RBL:0 FLG:0x0000
ktudb redo: siz: 188 spc: 3282 flg: 0x0022 seq: 0x0b4d rec: 0x1b
xid: 0x0001.002.000020c9
ktubu redo: slt: 2 rci: 26 opc: 11.1 objn: 104890 objd: 104890 tsn: 0
Undo type: Regular undo Undo type: Last buffer split: No
Tablespace Undo: No
0x00000000
KDO undo record:
KTB Redo
op: 0x02 ver: 0x01
compat bit: 4 (post-11) padding: 1
op: C uba: 0x01000087.0b4d.1a
KDO Op code: URP row dependencies Disabled
xtype: XA flags: 0x00000000 bdba: 0x0041af3d hdba: 0x0041af38
itli: 2 ispac: 0 maxfr: 4863
tabn: 0 slot: 7(0x7) flag: 0x2c lock: 0 ckix: 0
ncol: 3 nnew: 1 size: 0
col 2: [100]
79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79
79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79
79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79
79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79
CHANGE #2 CON_ID:1 TYP:0 CLS:1 AFN:1 DBA:0x0041af3d OBJ:104890 SCN:0x000000004fabda80 SEQ:8 OP:11.5 ENC:0 RBL:0 FLG:0x0000
KTB Redo
op: 0x02 ver: 0x01
compat bit: 4 (post-11) padding: 1
op: C uba: 0x01000087.0b4d.1b
KDO Op code: URP row dependencies Disabled
xtype: XA flags: 0x00000000 bdba: 0x0041af3d hdba: 0x0041af38
itli: 2 ispac: 0 maxfr: 4863
tabn: 0 slot: 7(0x7) flag: 0x2c lock: 2 ckix: 0
ncol: 3 nnew: 1 size: 0
col 2: [100]
78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78
78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78
78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78
78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78
--//没有字符z相关内容(7a 7a).
5.总结:
--//你可以发现oracle 18c在dml下修改字段前后如果信息不变,日志根本没有记录,这样一定程度减少日志大小.
[20181116]18c DML 日志优化.txt的更多相关文章
- [20181220]使用提示OR_EXPAND优化.txt
[20181220]使用提示OR_EXPAND优化.txt --//链接http://www.itpub.net/thread-2107240-2-1.html,http://www.itpub.ne ...
- [20190530]ORACLE 18c - ALTER SEQUENCE RESTART.txt
[20190530]ORACLE 18c - ALTER SEQUENCE RESTART.txt --//以前遇到要重置或者调整seq比较麻烦,我有时候采用比较粗暴的方式就是删除重建.--//18c ...
- [20190524]使用use_concat or_expand提示优化.txt
[20190524]使用use_concat or_expand提示优化.txt --//上午看了链接https://connor-mcdonald.com/2019/05/22/being-gene ...
- SecureCRT日志优化
SecureCRT日志优化 用了这么多ssh软件,但对secureCRT情有独钟.今天来对做一下对SecureCRT的优化 一.手动模式: 选择"File"->"L ...
- [20200223]关于latch and mutext的优化.txt
[20200223]关于latch and mutext的优化.txt --//前一段时间一直在测试使用DBMS_SHARED_POOL.MARKHOT标识热对象以及sql语句的优化.--//有别人问 ...
- mysql binlog日志优化及思路
在数据库安装完毕,对于binlog日志参数设置,有一些参数的调整,来满足业务需求或使性能最大化.Mysql日志主要对io性能产生影响,本次主要关注binlog 日志. 查一下二进制日志相关的参数 ...
- MySQL binlog日志优化
mysql中日志类型有慢查询日志,二进制日志,错误日志,默认情况下,系统只打开错误日志,因为开启日志会产生较大的IO性能消耗. 一般情况下,生成系统中很少打开二进制日志(bin log),bin ...
- Nginx优化之日志优化,URL访问控制,防盗链,及站点文件目录优化
Nginx日志相关优化与安全 日志切割脚本如下: #!/bin #日志切割脚本 Date=`date +%Y%m%d` Bdir="/usr/local/nginx" Nginxl ...
- C#中打日志导出日志到txt文本
/// <summary> /// 打日志 /// </summary> /// <param name="log"></param> ...
随机推荐
- 正则表达式的一些探索(偏JavaScript)
简单的探索下正则表达式的相关知识,首先先了解下正则表达式的引擎和匹配过程区别,再试着掌握如何在场景中编写正则表达式,再然后探索下根据上文已知的原理和编写过程怎么去优化正则表达式,最后给出一些js里正则 ...
- 【EF6学习笔记】(十一)实施继承
上篇链接:EF学习笔记(十) 处理并发 本篇原文链接:Implementing Inheritance 面向对象的世界里,继承可以很好的重用代码.在本章就对Instructor和Student两个类进 ...
- uml活动图
uml是程序员需要掌握一个重要工具,特别在研究hadoop(http://www.iigrowing.cn/hadoop)系统中,有很多相关的uml图形需要绘制,为了方便大家了解uml,在网络上找了些 ...
- JavaScript和Ajax部分(1)
1. JavaScript变量有哪些数据类型? JavaScript是一种弱类型语言,在声明变量时不需要指变量的类型,变量的类型由赋给变量的值来决定. 常用的基本数据类型: 1 undefined(未 ...
- Java——static关键字
前言 static关键字算是Java中比较复杂的关键字之一,它可以修饰变量.方法.类以及代码块.下面将介绍static的具体使用. static引入的目的 static的作用 static修饰变量 s ...
- #1 Python灵活技巧
前言 Python基础系列博文已顺利结束,从这一篇开始将进入探索更加高级的Python用法,Python进阶系列文章将包含面向对象.网络编程.GUI编程.线程和进程.连接数据库等.不过在进阶之前,先来 ...
- 翻译:赋值操作符(:=)(已提交到MariaDB官方手册)
本文为mariadb官方手册:赋值操作符(:=)的译文. 原文:https://mariadb.com/kb/en/assignment-operator/ 我提交到MariaDB官方手册的译文:ht ...
- Jenkins凭证及任务演示-pipeline(二)--技术流ken
Jenkins前言 在上一篇博客<Jenkins持续集成介绍及插件安装版本更新演示(一)--技术流ken>中已经详细介绍了jenkins的插件安装以版本更新等,本篇博客将再深入探究jenk ...
- golang高性能RPC:Apache Thrift安装使用完全攻略
在企业应用中RPC的使用可以说是十分的广泛,使用该技术可以方便的与各种程序交互而不用考虑其编写使用的语言. 如果你对RPC的概念还不太清楚,可以点击这里. 现今市面上已经有许多应用广泛的RPC框架,比 ...
- [PHP]算法-队列结构的PHP实现
题目描述 用两个栈来实现一个队列,完成队列的Push和Pop操作. 队列中的元素为int类型. 思路: 1.php数组完全就能实现 2.array_push 从尾部往里压入元素 3.array_shi ...