Chinaunix首页 | 论坛 | 博客
  • 博客访问: 671481
  • 博文数量: 845
  • 博客积分: 5000
  • 博客等级: 大校
  • 技术积分: 5015
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-15 16:22
文章分类

全部博文(845)

文章存档

2011年(1)

2008年(844)

我的朋友

分类:

2008-10-15 16:26:47

  Clean out有2种: fast commit cleanout

                            delayed block cleanout

  1,如果一个事务(transaction)修改不超过10%buffer cache的数据块时,oracle做的是fast commit cleanout。

  2,如果一个事务(transaction)修改的块超过10% buffer cache,那么"超过的块"就执行delayed block cleanout,

  3,在事务commit前,修改的数据块已经写入硬盘,当发生commit时,oracle并不会把block重新读入内存来做cleanout,这样成本太高.

  而是把cleanout留到下一次对此块的访问(select,update)时完成。

  下面我们来简单看一下这两种情况:

  --搭建环境

 

SQL> show parameter db_cache;
  NAME TYPE VALUE
  ------------------------------------ ----------- ------------------------------
  db_cache_size big integer 58720256

  --只需更改50M/10=5M的数据量就会触发DELAY CLEAN OUT

SQL> create table t2 (id int ,col1 char(2000),col2 char(2000),col3 char(2000),col4 char(1000));   

  表已创建。

      --1行一个块,

      SQL> insert into t2 select object_id,object_name,'1','1','1' from all_objects where rownum <=1000;
  已创建1000行。
  SQL> commit;
  SQL> select * from (
  2 select rownum rn, id,dbms_rowid.rowid_relative_fno(rowid) "file#",dbms_rowid.rowid_block_number(rowid) "block#" from t2 )
  3 where rn=1 or rn=1000;
  RN ID file# block#
  ---------- ---------- ---------- ----------
  1 7559 8 36
  1000 14700 8 1160
  --fast clean out 快速块清除
  SQL> update t2 set id=id,col1=col1,col2='c',col3='c',col4='c' where id='7559'; --第36块
  1 ROWS UPDATED
  SQL> select xidusn,xidslot,xidsqn,ubafil,ubablk,ubarec from v$transaction;
  XIDUSN XIDSLOT XIDSQN UBAFIL UBABLK UBAREC
  -------- ---------- ---------- ---------- ---------- ----------
  10 22 339 2 41167 11
  SQL> COMMIT;

  提交成功 

SQL> alter system dump datafile 8 block 36;

  系统已更改。

Start dump data blocks tsn: 8 file#: 8 minblk 36 maxblk 36
  buffer tsn: 8 rdba: 0x02000024 (8/36)
  scn: 0x0000.000b21db seq: 0x01 flg: 0x00 tail: 0x21db0601
  frmt: 0x02 chkval: 0x0000 type: 0x06=trans data
  Block header dump: 0x02000024
  Object id on Block? Y
  seg/obj: 0x739d csc: 0x00.b21db itc: 2 flg: E typ: 1 - DATA
  brn: 0 bdba: 0x2000021 ver: 0x01
  inc: 0 exflg: 0
  Itl Xid Uba Flag Lck Scn/Fsc
  0x01 0x000a.02b.00000152 0x0080a0c5.002a.2a C--- 0 scn 0x0000.000b218f
  0x02 0x000a.016.00000153 0x0080a0cf.002a.0b ---- 1 fsc 0x0000.00000000
  |
  |

    ----这里的FLAG已经清除

data_block_dump,data header at 0x3171064
  ===============
  tsiz: 0x1f98
  hsiz: 0x14
  pbl: 0x03171064
  bdba: 0x02000024
  76543210
  flag=--------
  ntab=1
  nrow=1
  frre=-1
  fsbo=0x14
  fseo=0x42d
  avsp=0x419
  tosp=0x419
  0xe:pti[0] nrow=1 offs=0
  0x12:pri[0] offs=0x42d
  block_row_dump:
  tab 0, row 0, @0x42d
  tl: 7019 fb: --H-FL-- lb: 0x2 cc: 5
  col 0: [ 3] c2 4c 3c
  col 1: [2000]
  2f 31 30 30 37 36 62 32 33 5f 4f 72 61 43 75 73 74 6f 6d 44 61 74 75 6d 43
  6c 6f 73 75 72 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
  20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20

      ... ... 数据内容部分省略  

20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
  col 2: [2000]
  63 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
  20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
  20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
  20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
  ... ...
  20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
  col 3: [2000]
  63 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
  ... ...
  20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
  col 4: [1000]
  63 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
  ... ...
  20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
  end_of_block_dump
  End dump data blocks tsn: 8 file#: 8 minblk 36 maxblk 36
  --delay clean out 延时块清除
  SQL> update t2 set id=id,col1=col1,col2='c',col3='c',col4='c'; --8M的更新数据
  已更新1000行。
  SQL> select xidusn,xidslot,xidsqn,ubafil,ubablk,ubarec from v$transaction;
  XIDUSN XIDSLOT XIDSQN UBAFIL UBABLK UBAREC
  ---------- ---------- ---------- ---------- ---------- ----------
  3 8 470 2 6788 1
  SQL> COMMIT;

  提交成功

[1]    

【责编:Chuan】

--------------------next---------------------
20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
  col 2: [2000]
  63 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
  20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
  20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
  20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
  ... ...
  20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
  col 3: [2000]
  63 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
  ... ...
  20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
  col 4: [1000]
  63 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
  ... ...
  20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
  end_of_block_dump
  End dump data blocks tsn: 8 file#: 8 minblk 36 maxblk 36
  --delay clean out 延时块清除
  SQL> update t2 set id=id,col1=col1,col2='c',col3='c',col4='c'; --8M的更新数据
  已更新1000行。
  SQL> select xidusn,xidslot,xidsqn,ubafil,ubablk,ubarec from v$transaction;
  XIDUSN XIDSLOT XIDSQN UBAFIL UBABLK UBAREC
  ---------- ---------- ---------- ---------- ---------- ----------
  3 8 470 2 6788 1
  SQL> COMMIT;
--------------------next---------------------

阅读(221) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~