您好,登錄后才能下訂單哦!
這篇文章主要介紹了Oracle中如何獲取v$latch數據源實驗,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
實驗環境:Oracle Rac 11.2.0.3
首先獲取v$latch的定義:
通過PL/SQL或者get ddl等常規途徑只能獲取到v_$latch相關的視圖信息。
需要通過特殊方法獲取v$latch的ddl
可以通過set autotrace traceonly開啟狀態下執行select * from v$latch;得知表的數據來源是x$kslltr,結果如下:
-----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 352 | 0 (0)| 00:00:01 |
|* 1 | FIXED TABLE FULL| X$KSLLTR | 1 | 352 | 0 (0)| 00:00:01 |
通過sql_trace的方式因為版本問題,trace的輸出結構略有不同,在11.2.0.4.5中可以獲取的ddl,但是在我的實驗環境中無法獲取,方法如下
alter session set sql_trace=true;
select * from v$latch;
alter session set sql_trace=false;
select * from v$diag_info where name='Default Trace File';
tkprof xxxx.trc
通過10053trace的方式獲取到v$latch的具體底層數據來源,方法如下
alter session set events '10053 trace name context forever,level 1';
select * from v$latch;
alter session set events '10053 trace name context off';
select * from v$diag_info where name='Default Trace File';
vim /u01/app/oracle/diag/rdbms/irac/IRAC1/trace/IRAC1_ora_16791.trc
注意!請不要使用sys用戶做10053 trace,你是得不到結果的。
得到如下結果,從輸出可以看出,最終轉換的sql語句如下;
Final query after transformations:******* UNPARSED QUERY IS *******
SELECT "LT"."KSLLTADDR" "ADDR","LT"."KSLLTNUM" "LATCH#","LT"."KSLLTLVL" "LEVEL#","LT"."KSLLTNAM" "NAME","LT"."KSLLTHSH" "HASH","LT"."KSLLTWGT" "GETS","LT"."KSLLTWFF" "MISSES","LT"."KSLLTWSL" "SLEEPS","LT"."KSLLTNGT" "IMMEDIATE_GETS","LT"."KSLLTNFA" "IMMEDIATE_MISSES","LT"."KSLLTWKC" "WAITERS_WOKEN","LT"."KSLLTWTH" "WAITS_HOLDING_LATCH","LT"."KSLLTHST0" "SPIN_GETS","LT"."KSLLTHST1" "SLEEP1","LT"."KSLLTHST2" "SLEEP2","LT"."KSLLTHST3" "SLEEP3","LT"."KSLLTHST4" "SLEEP4","LT"."KSLLTHST5" "SLEEP5","LT"."KSLLTHST6" "SLEEP6","LT"."KSLLTHST7" "SLEEP7","LT"."KSLLTHST8" "SLEEP8","LT"."KSLLTHST9" "SLEEP9","LT"."KSLLTHST10" "SLEEP10","LT"."KSLLTHST11" "SLEEP11","LT"."KSLLTWTT" "WAIT_TIME" FROM SYS."X$KSLLTR" "LT" WHERE "LT"."INST_ID"=USERENV('INSTANCE')
kkoqbc: optimizing query block SEL$88122447 (#0)
從而得到v$latch的底層數據來源。
當然,如果每次想看到官方文檔中沒有記載的視圖就去做一個10053trace,實在麻煩,可以使用如下方式,簡單方便的查詢到視圖的數據源:
SQL> SELECT * FROM v$fixed_view_definition WHERE view_name = 'V$LATCH';
VIEW_NAME
--------------------------------------------------------------------------------
VIEW_DEFINITION
--------------------------------------------------------------------------------
V$LATCH
select addr,latch#,level#,name,hash,gets,misses,sleeps,immediate_gets, immediate
_misses,waiters_woken,waits_holding_latch,spin_gets, sleep1,sleep2,sleep3,sleep4
,sleep5,sleep6,sleep7,sleep8,sleep9, sleep10,sleep11,wait_time from gv$latch whe
re inst_id = USERENV('Instance')
SQL> SELECT * FROM v$fixed_view_definition WHERE view_name = 'GV$LATCH';
VIEW_NAME
--------------------------------------------------------------------------------
VIEW_DEFINITION
--------------------------------------------------------------------------------
GV$LATCH
select lt.inst_id,lt.kslltaddr,lt.kslltnum,lt.kslltlvl,lt.kslltnam, lt.ks
llthsh,lt.kslltwgt,lt.kslltwff, lt.kslltwsl,lt.kslltngt,lt.kslltnfa,lt.ks
lltwkc, lt.kslltwth,lt.ksllthst0,lt.ksllthst1,lt.ksllthst2, lt.ksl
lthst3,lt.ksllthst4,lt.ksllthst5,lt.ksllthst6,lt.ksllthst7, lt.ksllthst8,
lt.ksllthst9,lt.ksllthst10, lt.ksllthst11, lt.kslltwtt from x$kslltr lt
SQL>
感謝你能夠認真閱讀完這篇文章,希望小編分享的“Oracle中如何獲取v$latch數據源實驗”這篇文章對大家有幫助,同時也希望大家多多支持億速云,關注億速云行業資訊頻道,更多相關知識等著你來學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。