如何查詢 library locking 問題
以下這些檢視都會記錄 pins/locks
DBA_KGLLOCK : one row for each lock or pin of the instance
-KGLLKUSE session address
-KGLLKHDL Pin/Lock handle
-KGLLKMOD/KGLLKREQ Holding/requested mode
0 no lock/pin held
1 null mode
2 share mode
3 exclusive mode
-KGLLKTYPE Pin/Lock
(created via the $ORACLE_HOME/rdbms/admin/catblock.sql)
V$ACCESS : one row for each object locked by any user
-SID session sid
-OWNER username
-OBJECT object name
-TYPE object type
V$DB_OBJECT_CACHE : one row for each object in the library cache
-OWNER object owner
-NAME object name or cursor text
-TYPE object type
-LOCKS number of locks on this object
-PINS number of pins on this object
DBA_DDL_LOCKS : one row for each object that is locked (exception made of the cursors)
-SESSION_ID
-OWNER
-NAME
-TYPE
-MODE_HELD
-MODE_REQUESTED
V$SESSION_WAIT : each session waiting on a library cache pin or lock is blocked by some other session
Following list give all objects that can be locked in the library cache:
-p1 = object address
-p2 = lock/pin address
以下sql可以查出等待和持有鎖的會話和型別 library locking
select /*+ ordered */ w1.sid waiting_session,
h1.sid holding_session,
w.kgllktype lock_or_pin,
w.kgllkhdl address,
decode(h.kgllkmod, 0, 'None', 1, 'Null', 2, 'Share', 3, 'Exclusive',
'Unknown') mode_held,
decode(w.kgllkreq, 0, 'None', 1, 'Null', 2, 'Share', 3, 'Exclusive',
'Unknown') mode_requested
from dba_kgllock w, dba_kgllock h, v$session w1, v$session h1
where
(((h.kgllkmod != 0) and (h.kgllkmod != 1)
and ((h.kgllkreq = 0) or (h.kgllkreq = 1)))
and
(((w.kgllkmod = 0) or (w.kgllkmod= 1))
and ((w.kgllkreq != 0) and (w.kgllkreq != 1))))
and w.kgllktype = h.kgllktype
and w.kgllkhdl = h.kgllkhdl
and w.kgllkuse = w1.saddr
and h.kgllkuse = h1.saddr
/
輸出的結果如下:
WAITING_SESSION HOLDING_SESSION LOCK ADDRESS MODE_HELD MODE_REQU
--------------- --------------- ---- -------- --------- ---------
16 12 Pin 03FA2270 Share Exclusive
select to_name from v$object_dependency where to_address = '03FA2270';
可以查出是什麼物件,比如儲存過程,包等
這個可以查出等待會話所執行的DDl語句
select distinct kglnaobj from x$kgllk where
kgllkuse in (select saddr from v$session where sid = 16);
這個可以查出持有者會話所執行的DDl語句
select distinct kglnaobj from x$kgllk where
kgllkuse in (select saddr from v$session where sid = 12);
以下物件會被鎖住在library cache
- INDEX
- TABLE
- CLUSTER
- VIEW
- SYNONYM
- SEQUENCE
- PROCEDURE
- FUNCTION
- PACKAGE
- PACKAGE BODY
- TRIGGER
- TYPE
- TYPE BODY
- OBJECT
- USER
- DBLINK
- PIPE
- TABLE PARTITION
- INDEX PARTITION
- LOB
- LIBRARY
- DIRECTORY
- QUEUE
- INDEX-ORGANIZED TABLE
- REPLICATION OBJECT GROUP
- REPLICATION PROPAGATOR
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7199859/viewspace-1758918/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- sql 模糊查詢問題SQL
- Xilinx問題查詢
- 斷號查詢問題
- library cache lock 阻塞程式查詢
- library cache pin 阻塞程式查詢
- 查詢Library Cache Pin等待原因
- 多維度分片需求,如何解決查詢問題?
- Laravel5.7 查詢問題Laravel
- sphinx查詢過濾問題
- 批次分頁查詢問題?
- hibernate批量查詢問題
- sql 查詢條件問題SQL
- 一個使用JDBC按Date查詢查詢的問題JDBC
- 查詢library cache lock的源頭
- SQLAlchemy in 查詢空列表問題分析SQL
- 分頁查詢的排序問題排序
- 模板中的名字查詢問題
- Hibernate的Criteria查詢問題。
- 批次查詢的翻頁問題
- 求助:DetachedCriteria關聯查詢問題~~
- leetcode題解(查詢表問題)LeetCode
- MySQL鎖表相關問題查詢思路MySql
- 一個MySQL多表查詢的問題MySql
- 【最佳化】模糊查詢索引問題索引
- 分頁查詢的排序問題(二)排序
- SQL語句巢狀查詢問題SQL巢狀
- plsql查詢亂碼問題解決SQL
- 從trc查詢死鎖的問題
- 併發查詢資料庫問題資料庫
- 關於Hibernate的查詢問題
- 一次效能問題原因查詢
- SQL Server 查詢超時問題排查SQLServer
- library cache lock\pin的查詢與處理
- Oracle效能問題檢查 - 常用查詢指令碼(final)Oracle指令碼
- python查詢mysql中文亂碼問題PythonMySql
- 關於 mysql 中的 rand () 查詢問題MySql
- beego orm join 聯合查詢的問題GoORM
- 關於restful 查詢API設計問題RESTAPI