Erp100论坛's Archiver

xiangzhao 发表于 2008-7-13 10:52

学习动态性能表(八)

[font=宋体]这个视图列出[/font][font=Times New Roman]Oracle [/font][font=宋体]服务器当前拥有的锁以及未完成的锁或栓锁请求。如果你觉着[/font][font=Times New Roman]session[/font][font=宋体]在等待等待事件队列那你应该检查本视图。如果你发现[/font][font=Times New Roman]session[/font][font=宋体]在等待一个锁。那么按如下先后顺序:[/font]
[font=Times New Roman]1.
[/font][font=宋体]使用[/font][font=Times New Roman]V$LOCK[/font][font=宋体]找出[/font][font=Times New Roman]session[/font][font=宋体]持有的锁。[/font]
[font=Times New Roman]2.
[/font][font=宋体]使用[/font][font=Times New Roman]V$SESSION[/font][font=宋体]找出持有锁或等待锁的[/font][font=Times New Roman]session[/font][font=宋体]执行的[/font][font=Times New Roman]sql[/font][font=宋体]语句。[/font]
[font=Times New Roman]3.
[/font][font=宋体]使用[/font][font=Times New Roman]V$SESSION_WAIT[/font][font=宋体]找出什么原因导致[/font][font=Times New Roman]session[/font][font=宋体]持有锁堵塞。[/font]
[font=Times New Roman]4.
[/font][font=宋体]使用[/font][font=Times New Roman]V$SESSION[/font][font=宋体]获取关于持有锁的程序和用户的更多信息。[/font]
[font=Times New Roman] [/font]
[b][font=Times New Roman]V$LOCK[/font][/b][b][font=宋体]中的常用列[/font][/b]
[font=Wingdings]l
[/font][font=Times New Roman]SID[/font][font=宋体]:表示持有锁的会话信息。[/font]
[font=Wingdings]l
[/font][font=Times New Roman]TYPE[/font][font=宋体]:表示锁的类型。值包括[/font][font=Times New Roman]TM[/font][font=宋体]和[/font][font=Times New Roman]TX[/font][font=宋体]等。[/font]
[font=Wingdings]l
[/font][font=Times New Roman]LMODE[/font][font=宋体]:表示会话等待的锁模式的信息。用数字[/font][font=Times New Roman]0[/font][font=宋体]-[/font][font=Times New Roman]6[/font][font=宋体]表示,和表[/font][font=Times New Roman]1[/font][font=宋体]相对应。[/font]
[font=Wingdings]l
[/font][font=Times New Roman]REQUEST[/font][font=宋体]:表示[/font][font=Times New Roman]session[/font][font=宋体]请求的锁模式的信息。[/font]
[font=Wingdings]l
[/font][font=Times New Roman]ID1,ID2[/font][font=宋体]:表示锁的对象标识。[/font]
[font=Times New Roman] [/font]
[b][font=宋体]公共锁类型[/font][/b]
[font=Times New Roman] [/font]
[font=宋体]  在[/font][font=Times New Roman]Oracle[/font][font=宋体]数据库中,[/font][font=Times New Roman]DML[/font][font=宋体]锁主要包括[/font][font=Times New Roman]TM[/font][font=宋体]锁和[/font][font=Times New Roman]TX[/font][font=宋体]锁,其中[/font][font=Times New Roman]TM[/font][font=宋体]锁称为表级锁,[/font][font=Times New Roman]TX[/font][font=宋体]锁称为事务锁或行级锁。[/font]
[font=Times New Roman] [/font]
[font=宋体]  当[/font][font=Times New Roman]Oracle[/font][font=宋体]执行[/font][font=Times New Roman]DML[/font][font=宋体]语句时,系统自动在所要操作的表上申请[/font][font=Times New Roman]TM[/font][font=宋体]类型的锁。当[/font][font=Times New Roman]TM[/font][font=宋体]锁获得后,系统再自动申请[/font][font=Times New Roman]TX[/font][font=宋体]类型的锁,并将实际锁定的数据行的锁标志位进行置位。这样在事务加锁前检查[/font][font=Times New Roman]TX[/font][font=宋体]锁相容性时就不用再逐行检查锁标志,而只需检查[/font][font=Times New Roman]TM[/font][font=宋体]锁模式的相容性即可,大大提高了系统的效率。[/font][font=Times New Roman]TM[/font][font=宋体]锁包括了[/font][font=Times New Roman]SS[/font][font=宋体]、[/font][font=Times New Roman]SX[/font][font=宋体]、[/font][font=Times New Roman]S[/font][font=宋体]、[/font][font=Times New Roman]X[/font][font=宋体]等多种模式,在数据库中用[/font][font=Times New Roman]0[/font][font=宋体]-[/font][font=Times New Roman]6[/font][font=宋体]来表示。不同的[/font][font=Times New Roman]SQL[/font][font=宋体]操作产生不同类型的[/font][font=Times New Roman]TM[/font][font=宋体]锁,如下表[/font][font=Times New Roman]1[/font][font=宋体]。[/font]

页: [1]

Powered by Discuz! Archiver 7.0.0  © 2001-2007 Comsenz Inc.