[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> ...
随机推荐
- Spring Boot 系列 - WebSocket 简单使用
在实现消息推送的项目中往往需要WebSocket,以下简单讲解在Spring boot 中使用 WebSocket. 1.pom.xml 中引入 spring-boot-starter-websock ...
- angular框架下的跨域问题(获取天气数据)
1.新浪天气:http://php.weather.sina.com.cn/iframe/index/w_cl.php?code=js&day=0&city=&dfc=1&am ...
- 基于Consul的数据库高可用架构
几个月没有更新博客了,已经长草了,特意来除草.本次主要分享如何利用consul来实现redis以及mysql的高可用.以前的公司mysql是单机单实例,高可用MHA加vip就能搞定,新公司mysql是 ...
- spark集群的简单测试和基础命令的使用
写此篇文章之前,已经搭建好spark集群并测试成功: spark集群搭建文章链接:http://www.cnblogs.com/mmzs/p/8193707.html 一.启动环境 由于每次都要启动, ...
- Tomcat的Https设置及Http自动跳转Https
Https相关介绍 Https是由NetScape公司设计的一个基于Http的加密传输协议,可以这样理解Https = Http +SSL(安全套接层),Https的端口为443,而且还需要申请 ...
- 利用http协议对搜索引擎劫持
主要是利用了http协议的refereer头 另外一个头user-agnet 主要是用来做流量劫持 referer 头告诉服务器用户从哪里找来的 当用户通过搜索引擎打开网站时会出现源网页 refere ...
- [javaEE] web应用的目录结构&配置虚拟主机
myWebSite | |-- 静态资源和JSP文件都可以直接放在web应用目录下,浏览器可以直接访问 |-- WEB-INF 浏览器没有办法直接访问 |-- classes 动态web运行时的cla ...
- springMVC_07乱码及restful风格
乱码的解决 通过过滤器解决乱码问题:CharacterEncodingFilter 配置web.xml文件 <filter> <filter-name>encoding< ...
- FastDFS搭建
a.上传安装时需要的文件 ①:FastDFS_v5.05.tar.gz ②:fastdfs-nginx-module_v1.16.tar.gz ③:libfastcommon-1.0.7.tar.gz ...
- The JRE_HOME environment variable is not defined correctly This environment
昨天启动tomcat还好好的,今天不知道抽什么风,cmd中报错: The JRE_HOME environment variable is not defined correctly This env ...