undo系列学习之深入浅出事务槽


Oracle数据块头部有个事务槽(ITL)。当多个事务槽同时修改数据块,而且,此时,pctfree(数据块空闲空间的比例)不足10%,则会出现ITL争用。这种现象容易发生在update和delete身上。因为,insert时,oracle会优先分散地插入其他空闲块。如:

看一下表a有多少个事务槽:

  1. sys@ORCL> select ini_trans,max_trans from dba_tables        
  2.   2        where owner='HR' and table_name='A';  
  3.   
  4.  INI_TRANS  MAX_TRANS  
  5. ---------- ----------   
  6.          1        255  

缺省下是1个,最多可以有255个

看一下表a用了多少个数据块:

  1. hr@ORCL> select dbms_rowid.rowid_relative_fno(rowid),   
  2.   2             dbms_rowid.rowid_block_number(rowid),  
  3.   3             id  
  4.   4        from a;  
  5.   
  6. DBMS_ROWID.ROWID_RELATIVE_FNO(ROWID) DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID)         ID  
  7. ------------------------------------ ------------------------------------ ----------   
  8.                                    4                                  460          1  
  9.                                    4                                  460          2  
  10.                                    4                                  460          3  
  11.                                    4                                  460          1  

可知:表a在4号文件上,第460个数据块。

可以把id=2,数据块为460的4号文件dump出来,看一下块头的ITL:

  1. alter system dump datafile 4 block 460  
  2.   
  3. sys@ORCL> select spid from v$process where addr in (select paddr from v$session  
  4.   2  where sid in (select sid from v$mystat where rownum=1));  
  5.   
  6. SPID  
  7. ------------   
  8. 10696  

ITL部分内容摘入如下:

  1. Block header dump:  0x010001cc  
  2.  Object id on Block? Y  
  3.  seg/obj: 0xce9d  csc: 0x00.15a47b  itc: 2  flg: E  typ: 1 - DATA  
  4.      brn: 0  bdba: 0x10001c9 ver: 0x01 opc: 0  
  5.      inc: 0  exflg: 0  
  6.   
  7.  Itl           Xid                  Uba         Flag  Lck        Scn/Fsc  
  8. 0x01   0x0003.025.000001fa  0x01c00566.0293.1e  ----    2  fsc 0x0000.00000000   
  9. 0x02   0x0004.020.00000151  0x0080068f.0144.11  C---    0  scn 0x0000.000f71fa  
  • 1
  • 2
  • 下一页

相关内容