Data dictionary locks保护在数据字典中的数据对象定义,保证数据字典的完整性,提供数据字典的一致性view。Data dictionary locks分成row cache locks、library cache locks和library cache pins(很少会发生)。
Data dictionary rows被存储在row cache中,作为shared pool的一部分。用来减少对sytem表空间的物理I/O。cache rows也作为一种resource structure,lock structure 被动态分配在shared pool中。Row cache lock在RAC环境中比较常见。Library cache locks也叫breakable pase locks。
DDL locks保证在语句解析和执行时数据对象定义的完整性,DMl locks保证事务的一致性transactional consistency。包括table locks(object definition consistency)和row locks(consistency of the data itself)。
在解析一个语句时,每个游标维持管理一系列table lock structures。在第一次游标执行时,一个函数可以被执行得到所有的table locks。这些lock在事务结束或者终止时,自动释放。一个coversation history table的存在而致使DML table lock可以被回退。DML_Locks参数控制table locks的数量。Free lists被dml lock allocation latch所维持。被使用的结构在v$locked_object中可以查询。为了设定dml table locks的数量,可以参考v$resource_limit。如果要使dml locks失效,可以用dml_locks to zero或者alter table × disable table locks来完成。
为了保证数据本身的完整性,Oracle server通过使用row levels和transaction locks来完成。Row levels是通过每个行头的锁位the lock byte in each data row header和在数据块或者索引块中的ITLs事务列表interested transaction lists来完成。行级别的锁如下图所示:
ITL是一种列表数据结构,列表中的每个节点记录了ITL slot信息和被锁定行的rowid,列表的最初长度由INITRANS确定,可动态扩展到最大至MAXTRANS设定的值,但扩展时有一前提就是块中要有足够的空间,如果块中没有足够的空间生成ITL slot,即使当前的slot书远未达到MAXTRANS值,也不可能在进行扩展。因此ITL是一种块级的队列,它的数量表示了该块的并发程度,如果ITL slot不够用,就会产生ITL waits,INITRANS和MAXTRANS在建表示使用存储参数指定。
Transaction identifiers(XID)是事务在系统中的唯一标识。在数据块的事务列表ITLs中使用。XID由Rollback/undo segment number、transaction table slot number和sequence number or wrap#组成,简称usn#+slot#+wrap#。
Buffer locks是用来保护buffer cache中的blocks的一致性。Buffer header充当resource structure,session使用buffer handles来访问buffers,而buffer handles就是其中的lock structures。Buffer busy waits event由三个参数来定位,p1(absolute file number)、p2(block number)和p3(reason code)。
为了达到减少buffer busy waits on data blocks,我们可以减少行密度(改变pctfree/pctused、initrans和alter table * minimize records_per_block命令或者改变db_block_size)和避免“right-hand ”indexes。
Undo segment contention在采用了automatic undo managed segment后,这个情况得到了很好的解决。一般结果这个问题级别上都是增加undo segments。或者利用参数transactions_per_rollback_segment。
Index block contention和data block contention相似。一般表现为index blocks split和bitmap index updates。你可以通过设定event 10224:”index block split /delete trace”去跟踪分析,通常发生在高的I/O的index data files上。
Free list contention一般发生在RAC的环境上,但是利用freelist groups的技术和cach fusion to transfer read-consistent block image from one instance to another,这个情况已经比较的少见。即使在single-instance environment,多free list groups也是对性能有帮助的。在locally managed tablespaces 中使用auto segment space managed (ASSM) segment,已经不需要specify the pctused,freelists and freelist groups parameters。解决free list contention的步鄹大概如下:
1、确定FILE,BLOCK and ID。
SQL> select event,p1 "file", p2 "block",p3 "ID"
from v$session_wait
where event='buffer busy waits';
2、identify the segment,using file and block。
SQL> select segment_name,segment_type
from dab_extents
where file_id=
and
3、get free lists for segment
SQL> select segment_name,freelists
From dba_segments
Where segment_name =
And segment_type=
4、recreate the freelist
SQL>alter table
Wait event:write complete waits暗示DBWn写的比较慢,可以通过RAID0+1 not RAID5、异步I/O or 多个wriiters和增加disk spindles的数量来完成。
ORA-1575的出现表明在space management(ST)上存在等待。可以利用locally managed tablespace、use temporary tablesapce、increase sort_area_size和设定pctincrease为0来削除。
Dba_free_space_coalesced是辨别SMON正在coalescing。也可以查询dba_free_space,这个数据字典是依据fet$(只显示字典管理的表空间)。SMON 的作用大概如下:
1、 merging or coalescing free extents(每5分钟)
2、 cleaning up temporary segments(每2小时)
3、 maintaining flashbacku scn to time mapping(每5分钟)
4、 cleaning up non existing objects in OBJ$(每12小时)
5、 cleaning up IND$(每小时)
6、 shrink undo segments(每12小时)
7、 transaction recovery on startup
8、 transaction rollback(when posted by pmon)
可以通过本地管理表空间和设定pctincrease to zero,使合并进程失效。当然也可以利用event=”10269 trace name context forever ,level 10”。利用alter tablespace
Temporary segment cleanup事件不应该成为问题。可以利用在临时表空间中排序和不要随便的终止一个进程而达到。你也可以利用”event=10061 trace name context forever ,level 10”来完成disable。