等待事件---enq:TX - row lock contention[zt]

等待事件---enq:TX - row lock contention

优化碰到的第一个wait event

enq是一种保护共享资源的锁定机制,一个排队机制,先进先出(FIFO)

发生TX锁的原因一般有几个

1.不同的session更新或删除同一个记录。

2.唯一索引有重复索引

3.位图索引多次更新

4.同时对同一个数据块更新

5.等待索引块分裂

通过数据系统视图检查果然是多个update的sql

select sid,username,event from v$session where stat in('WAITING') and wit_class!='Idle';

sid从上面的sql获得

select sid,sql_text from v$session a,v$sql b where sid in(282,496) and (b.sql_id=a.sql_id or b.sql_id=a.prev_sql_id);

-----------------------------------------------------------------------------------------------------

These are acquired exclusive when a transaction initiates its first change and held until the transaction does aCOMMITorROLLBACK.

  • Waits for TX in mode 6: occurs when a session is waiting for a row level lock that is already held by another session. This occurs when one user is updating or deleting a row, which another session wishes to update or delete. This type of TX enqueue wait corresponds to the wait eventenq:TX-rowlockcontention.

    The solution is to have the first session already holding the lock perform. aCOMMITorROLLBACK.

  • Waits for TX in mode 4 can occur if the session is waiting for an ITL (interested transaction list) slot in a block. This happens when the session wants to lock a row in the block but one or more other sessions have rows locked in the same block, and there is no free ITL slot in the block. Usually, Oracle dynamically adds another ITL slot. This may not be possible if there is insufficient free space in the block to add an ITL. If so, the session waits for a slot with a TX enqueue in mode 4. This type of TX enqueue wait corresponds to the wait eventenq:TX-allocateITLentry.

    The solution is to increase the number of ITLs available, either by changing theINITRANSorMAXTRANSfor the table (either by using anALTERstatement, or by re-creating the table with the higher values).

  • Waits for TX in mode 4 can also occur if a session is waiting due to potential duplicates inUNIQUEindex. If two sessions try to insert the same key value the second session has to wait to see if anORA-0001should be raised or not. This type of TX enqueue wait corresponds to the wait eventenq:TX-rowlockcontention.

    The solution is to have the first session already holding the lock perform. aCOMMITorROLLBACK.

  • Waits for TX in mode 4 is also possible if the session is waiting due to shared bitmap index fragment. Bitmap indexes index key values and a range of ROWIDs. Each 'entry' in a bitmap index can cover many rows in the actual table. If two sessions want to update rows covered by the same bitmap index fragment, then the second session waits for the first transaction to eitherCOMMITorROLLBACKby waiting for the TX lock in mode 4. This type of TX enqueue wait corresponds to the wait eventenq:TX-rowlockcontention.

  • Waits for TX in Mode 4 can also occur waiting for aPREPAREDtransaction.

  • Waits for TX in mode 4 also occur when a transaction inserting a row in an index has to wait for the end of an index block split being done by another transaction. This type of TX enqueue wait corresponds to the wait eventenq:TX-indexcontention.

------------------------------------------------------------------------------------

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/92530/viewspace-504750/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/92530/viewspace-504750/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值