[20211118]mutexprof指令碼使用簡介.txt
[20211118]mutexprof指令碼使用簡介.txt
--//mutexprof是 Tanel Poder編寫的指令碼,用於定位有關mutex的效能問題。抽空學習一下。
--//實際上剛一使用就遇到一個小問題。開發寫的sql語句使用\r chr(13)換行,導致我執行sqlplus的顯示介面是亂的。
--//我只能自己修改:
, nvl(decode(kglnaown, null, kglnaobj, kglnaown||'.'||kglnaobj), '(name not found)') msh_obj_name
--//替換為如下
, replace(nvl(decode(kglnaown, null, kglnaobj, kglnaown||'.'||kglnaobj), '(name not found)'),chr(13),'') msh_obj_name
--, nvl(decode(kglnaown, null, kglnaobj, kglnaown||'.'||kglnaobj), '(name not found)') msh_obj_name
--//一般很少生產系統出現mutex作為主要的等待事件的情況,這樣也就很少關注,除非遇到某個bug之類的情況。
--//實際上該命令包是自解析的,看看前面介紹基本知道如何使用。
-- Usage: @mutexprof <grouping columns> <filter condition>
--
-- The main grouping (and filtering) columns are:
--
-- id - mutex ID (which is the object hash value for library
-- cache object mutexes)
-- ts - timestamp of mutex sleep beginning
-- loc - code location where the waiter slept for the mutex
-- val - mutex value (shows whether mutex was held in exclusive or
-- shared mode)
-- req - requesting session SID
-- blk - blocking session SID
--
-- The filter condition allows filtering mutex sleep rows based on certain
-- criteria, such:
--
-- 1=1 - show all mutex sleeps (which are still in memory)
-- blk=123 - show only these mutex sleeps where blocking sid was 123
-- hash=2741853041 - show only these sleeps where mutex ID (KGL object hash value)
-- was 2741853041
--
--
-- Its also possible to have multiple "AND" filter conditions, as long as you keep
-- them in double quotes so that sqlplus would recognize them as one parameter
--
-- For example: "name like '%DUAL%' and blk in (115,98)"
--
-- Examples:
--
-- @mutexprof loc 1=1
-- @mutexprof id,loc,req,blk "lower(name) like 'select%from dual%'"
-- @mutexprof loc,val blk=98
-- @mutexprof id,loc,req,blk "blk in (select sid from v$session where username = 'SYS')"
--
-- Other: When the relevant object is aged out you will see (name not found)
-- as object_name.
--
-- On 10.2.0.1 the V$mutex_sleep_history does not have mutex_identifier
-- column externalized. In this case use X$mutex_sleep_history instead
ywdb> @mutexprof id,hash,loc ts>sysdate-15/1440
-- MutexProf by Tanel Poder ()
-- Showing profile of top 20 sleeps...
SLEEPS SLEEPS MUTEX_TYPE ID HASH GET_LOCATION OBJECT_NAME
---------- ------- --------------- ---------- ---------- --------------------------------- -------------------
6702 Library Cache 2536268875 2536268875 kglpsl1 38 MC$LOGFP2
5685 Library Cache 25675 kglhdgn1 62 (name not found)
4731 Library Cache 2536268875 2536268875 kgllkdl1 85 MC$LOGFP2
--//不要被前面第1列的SLEEPS迷惑,實際上這裡記錄的是最大值,第2列是最大減去最小的sleep,僅僅作為一個參考。
--//V$mutex_sleep_history來源gV$mutex_sleep_history,gV$mutex_sleep_history來源x$MUTEX_SLEEP_HISTORY,
--//x$MUTEX_SLEEP_HISTORY裡面有一個重要欄位MUTEX_ADDR,透過它可以定位具體物件。當然透過hash_value(MUTEX_IDENTIFIER)值也可
--//以,但是它僅僅是大概的範圍。
--//我自己始終對loc的縮略寫指向的具體位置不瞭解。
XXXX2> @mutexprof id,hash,loc ts>sysdate-5/1440
-- MutexProf by Tanel Poder ()
-- Showing profile of top 20 sleeps...
SLEEPS SLEEPS MUTEX_TYPE ID HASH GET_LOCATION OBJECT_NAME
---------- ------- --------------- ---------- ---------- --------------------------------- -----------------
739 597 Library Cache 2810066130 2810066130 kglpnal2 91 HZMCASSET.TAUDIT
4 Library Cache 3231142607 3231142607 kglpin1 4 SYS.DBMS_STANDARD
XXXX1> @mutexprof id,hash,loc ts>sysdate-1/1440
-- MutexProf by Tanel Poder ()
-- Showing profile of top 20 sleeps...
SLEEPS SLEEPS MUTEX_TYPE ID HASH GET_LOCATION OBJECT_NAME
---------- ------- --------------- ---------- ---------- --------------------------------- --------------------------------------------------------------------------------
30223 28932 Library Cache 3771887287 3771887287 kglget1 1 select count ( 0 ) from BSOFT_TEST_CONNECT
20833 19437 Library Cache 3771887287 3771887287 kgllkdl1 85 select count ( 0 ) from BSOFT_TEST_CONNECT
2187 Library Cache 1879237386 1879237386 kglpnal2 91 SYS.SQL_TXT
2033 744 Cursor Pin 2589686205 2589686205 kkslce [KKSCHLPIN2] SELECT PD_LSDL.DLID, PD_LSDL.RDID, PD_LSDL.RDSJ,
PD_LSDL.PDHM, PD_LSDL.PDCY, PD_LSDL.PDZT,
PD_LSDL.KSSJ, PD_LSDL.JSSJ, PD_LSDL.DDSJ,
PD_LSDL.WCSJ, PD_LSDL.JLSJ, PD_LSDL.SLGH,
PD_LSDL.SLRM, PD_LSDL.KSID, PD_LSDL.KSMC,
PD_LSDL.YSID, PD_LSDL.YSXM, PD_LSDL.QTID,
PD_LSDL.QTMC, PD_LSDL.YWLB, PD_LSDL.YWID,
PD_LSDL.BRID FROM PD_LSDL WHERE PD_LSDL.WCSJ >= :adt_Begin AND
PD_LSDL.WCSJ < :adt_End AND PD_LSDL.SLGH = :as_slgh
--//前面2條是我們生產系統登入必須執行的sql語句,而且幾乎每個schema下都有這樣一個表。呼叫很頻繁。我沒有把一些程式設定為
--//cursor_sharing=force.
--// SELECT PD_LSDL.DLID .. 有時候真心無語,我已經提交,這條語句無法執行的,沒有PD_LSDL.DLID欄位。
XXXX1> @ sharepool/shp4 0 2589686205
TEXT KGLHDADR KGLHDPAR KGLHDLMD KGLHDPMD KGLHDIVC KGLOBHD0 KGLOBHD6 KGLOBHS0 KGLOBHS6 KGLOBT16 N0_6_16 N20 KGLNAHSH KGLOBT03 KGLOBT09
--------------------- ---------------- ---------------- ---------- ---------- ---------- ---------------- ---------------- ---------- ---------- ---------- --------- ---------- ---------- ------------- ----------
child handle address 000000130AEEDE08 0000001302AB8D68 0 0 6506874 00 00 0 0 6724 6724 6724 2589686205 b0u9avfd5qydx 0
child handle address 000000130A6A84A8 0000001302AB8D68 0 0 3467 00 00 0 0 6724 6724 6724 2589686205 b0u9avfd5qydx 1
child handle address 0000001306CCEA98 0000001302AB8D68 0 0 3 00 00 0 0 6724 6724 6724 2589686205 b0u9avfd5qydx 2
child handle address 0000001306CCE928 0000001302AB8D68 0 0 4 00 00 0 0 6724 6724 6724 2589686205 b0u9avfd5qydx 3
child handle address 000000008C0859D8 0000001302AB8D68 0 0 1 00 00 0 0 6724 6724 6724 2589686205 b0u9avfd5qydx 4
parent handle address 0000001302AB8D68 0000001302AB8D68 1 0 6510349 0000001308A69CF0 00 9464 0 0 9464 9464 2589686205 b0u9avfd5qydx 65535
6 rows selected.
--//子游標沒有堆0,堆6資訊。
--//10g早期版本V$mutex_sleep_history沒有mutex_identifier欄位,建議使用X$mutex_sleep_history代替。
--//我建立新的mutexprofx.sql,加入mutex_addr欄位。
$ diff -Nur mutexprof.sql mutexprofx.sql
--- mutexprof.sql 2021-11-18 10:10:18.000000000 +0800
+++ mutexprofx.sql 2021-11-19 08:51:49.000000000 +0800
@@ -63,6 +63,8 @@
col mutexprof_p4 head P4 for a16 wrap
col mutexprof_p5 head P5 for a20 wrap
+col maddr head mutex_addr for a20 wrap
+
def MSH_NUMROWS=20
prompt
@@ -98,13 +100,14 @@
, blocking_session blk
, location loc
, mutex_value val
+ , mutex_addr maddr
, p1
, p1raw
, p2
, p3
, p4
, p5
- from v$mutex_sleep_history) m
+ from x$mutex_sleep_history) m
, (select kglnahsh, kglnahsh hash_value, kglnahsh hash,
kglhdpar, kglhdadr, kglnaown, kglnaobj,
decode(kglnaown, null, kglnaobj, kglnaown||'.'||kglnaobj) object_name,
XXXX1> @mutexprofx id,hash,loc,maddr ts>sysdate-1/1440
-- MutexProf by Tanel Poder ()
-- Showing profile of top 20 sleeps...
SLEEPS SLEEPS MUTEX_TYPE ID HASH GET_LOCATION mutex_addr OBJECT_NAME
---------- ------- --------------- ---------- ---------- --------------------------------- -------------------- ------------------------------------------
237618 236174 Library Cache 3771887287 3771887287 kglget1 1 000000130B9B3560 select count ( 0 ) from BSOFT_TEST_CONNECT
2109 700 Library Cache 3771887287 3771887287 kgllkdl1 85 000000130B9B3560 select count ( 0 ) from BSOFT_TEST_CONNECT
--//這樣可以獲取mutex_addr.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2843009/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20200117]ashtop指令碼使用簡介.txt指令碼
- HTML 指令碼簡介HTML指令碼
- Bash 指令碼簡介指令碼
- MHA常用指令碼簡介指令碼
- (1) Shell 指令碼簡介指令碼
- Shell指令碼介紹與使用指令碼
- Unity引擎與C#指令碼簡介UnityC#指令碼
- 面向 DBA 的 Linux Shell 指令碼簡介Linux指令碼
- MySQL使用XtraBackup的shell指令碼介紹MySql指令碼
- redis中lua指令碼的簡單使用Redis指令碼
- Python Plumbum 簡介:用 Python 來寫指令碼Python指令碼
- Jira使用簡介 HP ALM使用簡介
- [20150821]簡單編寫解除阻塞的指令碼.txt指令碼
- 使用命令幫助簡化管理指令碼指令碼
- MySQL初始化指令碼mysql_install_db使用簡介及選項引數MySql指令碼
- [20170628]完善ooerr指令碼.txt指令碼
- outline操作指令碼_老版本.txt指令碼
- Oracle管理指令碼介紹Oracle指令碼
- pm2 簡介與常用指令
- Verilog 編譯指令簡介編譯
- 持久記憶體指令(PMDK)簡介記憶體
- [20240313]使用tpt ashtop.sql指令碼的困惑.txtSQL指令碼
- 陣列-在Shell指令碼中的基本使用介紹陣列指令碼
- 誰說設計師不會寫程式碼?—Photoshop指令碼語言簡介指令碼
- [20210330]bash使用source or ..呼叫shell指令碼注意txt指令碼
- pipenv 使用簡介
- dremio使用簡介REM
- Git 使用簡介Git
- Disruptor 使用簡介
- ActiveMQ使用簡介MQ
- Sysbench使用簡介
- Sed使用簡介
- vagrant使用簡介
- 簡單介紹Shell指令碼之檔案批次建立與修改的方法指令碼
- Turbo碼原理簡介
- [20210506]完善tix指令碼.txt指令碼
- 快速入門Redis呼叫Lua指令碼及使用場景介紹Redis指令碼
- Quick-Task 動態指令碼支援框架之使用介紹篇UI指令碼框架