企业如何通过vue小程序开发满足高效运营与合规性需求
374
2023-12-30
这篇文章主要介绍了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 ltSQL>
感谢你能够认真阅读完这篇文章,希望小编分享的“Oracle中如何获取v$latch数据源实验”这篇文章对大家有帮助,同时也希望大家多多支持,关注行业资讯频道,更多相关知识等着你来学习!
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~