[20130520]统计那个对象生成的redo多.txt

[20130520]统计那个对象生成的redo多.txt

http://timothyhopkins.net/2009/09/summarise-redo-by-object/

如果统计那个对象生成的redo多,一直是我比较头疼的问题.我以前遇到3次程序员编程错误,导致生成大量redo,要找到这些问题
可以通过awr,ash等报表,logminer来确定是那个对象执行问题,但是有时候定位问题并不是很好.

昨天找到以上链接,通过dump redo或者archivelog就可以知道那些对象生成的redo多.自己测试看看.

1.建立测试环境:

SQL> @ver
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
SQL> select * from v$diag_info where name='Default Trace File';
   INST_ID NAME                 VALUE
---------- -------------------- --------------------------------------------------------------------------------------
         1 Default Trace File   /u01/app/oracle11g/diag/rdbms/test/test/trace/test_ora_2878_local.trc
create table t1 as select * from dba_objects;
create table t2 as select * from t1;
create table t3 as select * from t1 where 1=0;
create index i_t1_object_id on t1(object_id);
alter system switch logfile ;
SQL> alter system checkpoint;
System altered.
SQL> select * from v$log order by group#;
    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIME          NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ------------------- ------------ -------------------
         1          1        424   52428800        512          1 YES INACTIVE            3229333374 2013-05-20 10:07:58   3229337621 2013-05-20 10:08:36
         2          1        425   52428800        512          1 YES INACTIVE            3229337621 2013-05-20 10:08:36   3229338070 2013-05-20 10:12:25
         3          1        426   52428800        512          1 NO  CURRENT             3229338070 2013-05-20 10:12:25   2.8147E+14

--确定跟踪文件以及当前使用那个redo sequence#=426.

2.建立测试:

delete from t1;
commit;
update t2 set OBJECT_NAME=lower(OBJECT_NAME);
commit ;
insert into t3  select * from t2;
commit ;
alter system switch logfile ;
SQL> select * from v$logfile order by group#;
    GROUP# STATUS  TYPE                                     MEMBER                                                       IS_
---------- ------- ---------------------------------------- ------------------------------------------------------------ ---
         1         ONLINE                                   /u01/app/oracle11g/oradata/test/redo01.log                   NO
         2         ONLINE                                   /u01/app/oracle11g/oradata/test/redo02.log                   NO
         3         ONLINE                                   /u01/app/oracle11g/oradata/test/redo03.log                   NO
SQL> select * from v$log order by group#;
    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIME          NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ------------------- ------------ -------------------
         1          1        427   52428800        512          1 YES ACTIVE              3229342316 2013-05-20 10:14:06   3229345486 2013-05-20 10:14:09
         2          1        428   52428800        512          1 NO  CURRENT             3229345486 2013-05-20 10:14:09   2.8147E+14
         3          1        426   52428800        512          1 YES ACTIVE              3229338070 2013-05-20 10:12:25   3229342316 2013-05-20 10:14:06

--从结果可以看出使用redo sequence是426以及427,两个redo文件.(当前是428).

3.转储 redo文件:

sql> alter system dump logfile '/u01/app/oracle11g/oradata/test/redo03.log';
sql> alter system dump logfile '/u01/app/oracle11g/oradata/test/redo01.log';
$ perl redo_summary.pl /u01/app/oracle11g/diag/rdbms/test/test/trace/test_ora_2878_local.trc
           OBJECT_ID                                REDO_SIZE
              274946                                 31144940
              274945                                 29023956
              274948                                 16169668
              274947                                  8666276
     NON-OBJECT REDO                                   650224
                   1                                    13820
                   0                                     5132
               68377                                     2332
                 289                                     2096
                  14                                     1388
                 383                                     1372
               67679                                     1352
                 287                                     1096
                   4                                      808
                 132                                      528
                 133                                      240
SQL> select object_name,object_id,data_object_id from dba_objects where wner=user and object_name like 'T_' or object_name ='I_T1_OBJECT_ID'order by 1;
OBJECT_NAME           OBJECT_ID DATA_OBJECT_ID
-------------------- ---------- --------------
I_T1_OBJECT_ID           274948         274948
T1                       274945         274945
T2                       274946         274946
T3                       274947         274947

--T1(object_id=274945)做的操作是delete操作,redo_size=29023956.
--T2(object_id=274946)做的操作是update操作,redo_size=31144940.
--T3(object_id=274947)做的操作是insert操作,redo_size= 8666276.
-- object_id=274948 是T1上的索引,可以发现产生的redo也不少.redo_size=16169668.

4.转储archivelog看看,应该结果也是一致的,另外产生的文件很大,我的测试
$ du -sm /u01/app/oracle11g/diag/rdbms/test/test/trace/test_ora_2878_local.trc
415     /u01/app/oracle11g/diag/rdbms/test/test/trace/test_ora_2878_local.trc
--415M.

--作者的链接使用管道文件,我也测试看看.这样不消耗磁盘空间.

SQL> select * from v$diag_info where name='Default Trace File';
   INST_ID NAME                 VALUE
---------- -------------------- --------------------------------------------------------------------------------------
         1 Default Trace File   /u01/app/oracle11g/diag/rdbms/test/test/trace/test_ora_3733_local.trc
$ mkfifo /u01/app/oracle11g/diag/rdbms/test/test/trace/test_ora_3733_local.trc
SQL> show parameter log_archive_dest_1
NAME                TYPE      VALUE
------------------- --------- ---------------------------------------
log_archive_dest_1  string    LOCATION=/u01/app/oracle11g/archivelog
$ ls -l /u01/app/oracle11g/archivelog/1_42[67]_798551880.dbf
-rw-r-----  1 oracle11g oinstall 46671360 2013-05-20 10:14:07 /u01/app/oracle11g/archivelog/1_426_798551880.dbf
-rw-r-----  1 oracle11g oinstall 41971712 2013-05-20 10:14:09 /u01/app/oracle11g/archivelog/1_427_798551880.dbf
$ perl redo_summary.pl /u01/app/oracle11g/diag/rdbms/test/test/trace/test_ora_3733_local.trc
sql> alter system dump logfile '/u01/app/oracle11g/archivelog/1_426_798551880.dbf';
sql> alter system dump logfile '/u01/app/oracle11g/archivelog/1_426_798551880.dbf';
SQL> alter system dump logfile '/u01/app/oracle11g/archivelog/1_426_798551880.dbf';
alter system dump logfile '/u01/app/oracle11g/archivelog/1_426_798551880.dbf'
*
ERROR at line 1:
ORA-48186: OS check file exists system call failure
Additional information: 3
--11G不行.还是采用文件的方式.
$ perl redo_summary.pl /u01/app/oracle11g/diag/rdbms/test/test/trace/test_ora_3733_local.trc
           OBJECT_ID                                REDO_SIZE
              274946                                 31144940
              274945                                 29023956
              274948                                 16169668
              274947                                  8666276
     NON-OBJECT REDO                                   650224
                   1                                    13820
                   0                                     5132
               68377                                     2332
                 289                                     2096
                  14                                     1388
                 383                                     1372
               67679                                     1352
                 287                                     1096
                   4                                      808
                 132                                      528
                 133                                      240

5.采用别的方式认证看看:
--删除重新建立看看.
SQL> set autotrace traceonly ;
SQL> delete from t1;
  45510392  redo size
-- 29023956 + 16169668=45193624 ,很接近.

SQL> update t2 set OBJECT_NAME=lower(OBJECT_NAME);
  27756536  redo size
-- 31144940 有一些差距,不知道为什么?

SQL> insert into t3  select * from t2;
    9011404  redo size
--  8666276 还是有一些差距.

6.附上redo_summary.pl的脚本:
--BTW,好像不复杂,但是我没看懂,不知道得出的结果是否正确.^_^.
http://timothyhopkins.net/wp-content/uploads/2009/09/redo_summary.zip

$ cat redo_summary.pl
# TDH 2008-09-26
# Analyses a formatted redo dump and
#       summarises redo bytes by object.
#

my $current_object;
my $current_bytes;
my %object_bytes = ();

sub DescendingNum {
   $object_bytes{$b} $object_bytes{$a};
}

while () {

        if (/LEN: 0x([a-f0-9A-F]+) VLD/) {

                if (defined($current_object)) {
                        $object_bytes{$current_object} += $current_bytes;
                }
                elsif (defined($current_bytes)) {
                        $object_bytes{"NON-OBJECT REDO"} += $current_bytes;
                }

                $current_bytes = hex($1);
                $current_object = undef;
        }
        elsif (/objn: (\d+) objd/) {
                $current_object = $1;
        }
}

printf "%20s %40s\n","OBJECT_ID","REDO_SIZE";

foreach my $key (sort DescendingNum(keys(%object_bytes))) {
                printf "%20s %40s\n",$key,$object_bytes{$key};
}

时间: 2024-10-14 11:06:42

[20130520]统计那个对象生成的redo多.txt的相关文章

Linux下控制(统计)文件的生成的C代码实现_C 语言

本文分享了Linux下控制(统计)文件的生成的C代码实现案例,供大家参考,具体内容如下 一.需求描述 不定时地在Linux机器下的某目录中放入文件,文件内容中包含了用户号码.起止时间等字段,现要求编写一程序来统计目前该目录中所有文件中的记录总条数及所有记录中的最早起始时间和最晚结束时间. 例如,该目录中有两个文件Test_1.txt和Test_2.txt,其中Test_1.txt文件内容为: 15696192591|15696192592|20151103 120909|20151103 201

根据对象生成参数,生成500000个对象插入的数据库表里面,A帐户登陆点击生成,需要n个小时,如做到点击生成后,当前页面提示生成中,和何避免B帐户登陆进来再次点

问题描述 根据对象生成参数,生成500000个对象插入的数据库表里面,A帐户登陆点击生成,需要n个小时,如做到点击生成后,当前页面提示生成中,和何避免B帐户登陆进来再次点击生成 解决方案 解决方案二:具体看你业务了.a和b用户的角色一样?都可以生成?然后只能有一个生成的?可以根据业务想办法设定生成状态,让b用户点击生成时,提示生产中的状态.解决方案三:后台做一个同步锁,成功之后返回修改一个静态值isbuss=B,进入方法之前isbuss=A登录进入之后用一个方法查询isbuss是否等于B如果不等

java class加载机制及对象生成机制

java class加载机制及对象生成机制 当使用到某个类,但该类还未初始化,未加载到内存中时会经历类加载.链接.初始化三个步骤完成类的初始化.需要注意的是类的初始化和链接的顺序有可能是互换的. ClassLoader加载机制 ClassLoader用于动态加载class文件到内存中. Java 提供了三个ClassLoader: 启动类加载器(BootStrap ClassLoader):java类加载器中最顶层的类加载器,负责加载jdk中核心的类库,如:rt.jar.resources.ja

[20141111]11G redo暴涨.txt

[20141111]11G redo暴涨.txt --新上线生产系统日志出现暴涨,当天达到了400G,正常业务每天7G上下,导致dataguard,备份出现问题,磁盘空间不足 --自己做一些调查: SYS@xxxx> @ ver1 PORT_STRING                    VERSION        BANNER ------------------------------ -------------- -----------------------------------

[20170411]bbed计算redo检查和.txt

[20170411]bbed计算redo检查和.txt --前一阵子做测试,需要一个计算器做异或的操作,链接http://blog.itpub.net/267265/viewspace-2134945/ --正好前几天开会遇到熟人,谈起我写的脚本很实用.我说不支持管道操作不是很好,对方讲支持,他自己就是这样用的. $ cat ~/bin/xor.sh #! /bin/bash # just play , calc xor!! s='0' for i in $(cat $1| tr 'a-f' '

[20170308]关于redo dump.txt

[20170308]关于redo dump.txt --//前一阵子在探究是否可以备库的备用日志来恢复主库,当主库在线日志丢失的情况下.遇到一些问题. DUMP OF REDO FROM FILE '/mnt/ramdisk/book/redo01.log' Opcodes *.* RBAs: 0x000000.00000000.0000 thru 0xffffffff.ffffffff.ffff SCNs: scn: 0x0000.00000000 thru scn: 0xffff.fffff

Linux下控制(统计)文件的生成的C代码实现

需求描述 不定时地在Linux机器下的某目录中放入文件,文件内容中包含了用户号码.起止时间等字段,现要求编写一程序来统计目前该目录中所有文件中的记录总条数及所有记录中的最早起始时间和最晚结束时间. 例如,该目录中有两个文件Test_1.txt和Test_2.txt,其中Test_1.txt文件内容为: 15696192591|15696192592|20151103 120909|20151103 201545| 15696192593|15696192594|20151103 110909|2

为自定义对象生成随机属性值

这几天在熟悉Swagger的时候,发现它没有提供为自定义对象属性赋随机值的功能(如果有的话,请告知一下),于是自己就写了一个能生成对象随机属性值的工具类,主要用到了反射机制.注解.随机类.具体的代码如下所示: 随机生成对象属性值的类: public class RandomObjectValue { public static <T> T getObject(Class<?> clazz) { T t = null; if (clazz == null) { return t; }

常见dml、ddl语句使用nologging选项所生成的redo和undo大小比较

说明:反映undo.redo占用量的统计指标是: undo change vector size redo size   DDL/DML Operations Direct-path nologging parallel noarchivelog mode archivelog mode Redo Undo Redo Undo Insert into XXX select * from YYY N N N 19076324 627240 18938620 612980 Alter table X