你好,游客 登录 注册 搜索
背景:
阅读新闻

Oracle 下操作blob字段是否会产生大量redo

[日期:2014-06-05] 来源:Linux社区  作者:stevendbaguo [字体:大 中 小]

--做很多次
 insert into test_blob  select * from test_blob;
 
insert into test_blob  select * from test_blob;
 

insert into test_blob  select * from test_blob;
 

.......
 
commit;
 
--准备dump block
 
select rowid,
        dbms_rowid.rowid_object(rowid) object_id,
        dbms_rowid.rowid_relative_fno(rowid) file_id,
        dbms_rowid.rowid_block_number(rowid) block_id,
        dbms_rowid.rowid_row_number(rowid) num
  from test_blob;
 

--update之前blob的状态
 
alter session set tracefile_identifier = 'Look_For_Me';
 alter system switch logfile;
 alter system switch logfile;
 alter system dump datafile 5 block 3274932;
 
--update之后blob的状态,同时测试一下,此时update产生了多少redo
 select name, value
  from v$mystat, v$statname
  where v$mystat.statistic# = v$statname.statistic#
    and v$statname.name = 'redo size'
 update test_blob set tupian = null;
 commit;
 
select name, value
  from v$mystat, v$statname
  where v$mystat.statistic# = v$statname.statistic#
    and v$statname.name = 'redo size'
 

alter system switch logfile;
 alter system switch logfile;
 alter session set tracefile_identifier = 'Look_For_Me1';
 alter system dump datafile 5 block 3274932;
 
测试结果:我传的图片是5.1M,一共产生了350条数据,都把blob置为空以后,共产生了7.6M的redo,很显然是blob的内容是没有产生redo的。
 
分析原理,得借助分析dump block的内容,可以看到设置blob字段为null后产生的redo只是类似col  1: [84]这些信息。
 
blob设置为空以前:
 
Block header dump:  0x0171f8b4
  Object id on Block? Y
  seg/obj: 0x17f1d  csc: 0x9a8.7256c728  itc: 2  flg: E  typ: 1 - DATA
      brn: 0  bdba: 0x171f8b0 ver: 0x01 opc: 0
      inc: 0  exflg: 0
 
  Itl          Xid                  Uba        Flag  Lck        Scn/Fsc
 0x01  0x0003.01b.000033cf  0x00c001f5.132c.39  --U-    1  fsc 0x0000.7256c775
 0x02  0x0000.000.00000000  0x00000000.0000.00  ----    0  fsc 0x0000.00000000
 bdba: 0x0171f8b4
 data_block_dump,data header at 0x2b35c4c56064
 ===============
 tsiz: 0x1f98
 hsiz: 0x14
 pbl: 0x2b35c4c56064
      76543210
 flag=--------
 ntab=1
 nrow=1
 frre=-1
 fsbo=0x14
 fseo=0x1f12
 avsp=0x1f29
 tosp=0x1f29
 0xe:pti[0]  nrow=1
 offs=0
 0x12:pri[0]  offs=0x1f12
 block_row_dump:
 tab 0, row 0, @0x1f12
 tl: 91 fb: --H-FL-- lb: 0x1  cc: 2
 col  0: [ 2]  c1 02
 col  1: [84]
  00 54 00 01 01 0c 00 00 00 01 00 00 00 01 00 00 00 0e 48 41 00 40 05 00 00
  00 02 76 12 a0 00 00 00 00 00 02 01 71 f8 bc 01 71 f8 bd 01 71 f8 be 01 71
  f8 bf 01 71 f8 bb 01 ca 11 3d 01 ca 11 3e 01 ca 11 3f 01 ca 11 39 01 ca 11
  3a 01 ca 11 3b 01 ca 11 3c
 LOB
 Locator:
  Length:        84(84)
  Version:        1
  Byte Length:    1
  LobID: 00.00.00.01.00.00.00.0e.48.41
  Flags[ 0x01 0x0c 0x00 0x00 ]:
    Type: BLOB
    Storage: BasicFile
    Enable Storage in Row
    Characterset Format: IMPLICIT
    Partitioned Table: No
    Options: ReadWrite
  Inode:
    Size:    64
    Flag:    0x05 [ Valid InodeInRow(ESIR) ]
    Future:  0x00 (should be '0x00')
    Blocks:  630
    Bytes:    4768
    Version:  00000.0000000002
    DBA Array[12]:
      0x0171f8bc 0x0171f8bd 0x0171f8be 0x0171f8bf
      0x0171f8bb 0x01ca113d 0x01ca113e 0x01ca113f
      0x01ca1139 0x01ca113a 0x01ca113b 0x01ca113c
 

............................................................
 
............................................................
 
End dump data blocks tsn: 6 file#: 5 minblk 3274932 maxblk 3274932
 

 


blob设置为空之后:
 

Block header dump:  0x0171f8b4
  Object id on Block? Y
  seg/obj: 0x17f1d  csc: 0x9a8.7256c99f  itc: 2  flg: E  typ: 1 - DATA
      brn: 0  bdba: 0x171f8b0 ver: 0x01 opc: 0
      inc: 0  exflg: 0
 
  Itl          Xid                  Uba        Flag  Lck        Scn/Fsc
 0x01  0x0003.01b.000033cf  0x00c001f5.132c.39  C---    0  scn 0x09a8.7256c775
 0x02  0x0001.003.0000315e  0x00c0218e.1348.3a  --U-    1  fsc 0x0052.7256c9a7
 bdba: 0x0171f8b4
 data_block_dump,data header at 0x2b7ad6cce464
 ===============
 tsiz: 0x1f98
 hsiz: 0x14
 pbl: 0x2b7ad6cce464
      76543210
 flag=--------
 ntab=1
 nrow=1
 frre=-1
 fsbo=0x14
 fseo=0x1f0c
 avsp=0x1f29
 tosp=0x1f7b
 0xe:pti[0]  nrow=1
 offs=0
 0x12:pri[0]  offs=0x1f0c
 block_row_dump:
 tab 0, row 0, @0x1f0c
 tl: 6 fb: --H-FL-- lb: 0x2  cc: 1
 col  0: [ 2]  c1 02
 

 

............................................................
 
............................................................
 

End dump data blocks tsn: 6 file#: 5 minblk 3274932 maxblk 3274932

本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-06/102740.htm

linux
相关资讯       Oracle blob 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款