Latch:shared Pool Latch:library Cache Diagnostic script (latchprofx.sql,latchprof.sql)

Source: Internet
Author: User

This is done in the following ways:

@d:\latchprofx.sql sid,name,laddr% Cache 10000

@d:\latchprof.sql sid,name,laddr% Cache 10000

Script Source: http://www.tanelpoder.com

Latchprofx.sql
------------------------------------------------------------------------------------File Name:latchprofx.sql ( Latch Holder Profiler eXtended)--purpose:perform high-frequency sampling on v$latchholder--and Presen              T a profile of latches held by sessions--including extended statistics on which kernel--              Function The latch held was taken----Author:tanel poder--Copyright: (c) http://www.tanelpoder.com-- --Usage: @latchprofx <what> <sid> <latch name> < #samples >--@latchprofx name 100000-monitor all latches SID holding--@latchprofx sid,name% Library 1000 000-monitor which SIDs hold latches with "library" in their name--@latchprofx sid,name,laddr% 40 D993a0 100000-monitor which SIDs hold child latch with address 0x40d993a0--@latchprofx Sid,name,func%                     % 100000--                                         -Monitor all sessions and latches and show--                                                              -Latch Get Where info (locations in kernel code--  -Where the latch get is done)----@latchprofx Sid,name,hmode,func "Cache buffers Chains" 100000---monitor functions that took latch for SID                                                              ---and report only "cache buffers chains" latch holders--              -also report hold mode Hmode (shared or exclusive)----                                                              @latchprofx Sid,name,hmode,func,object% 40d993a0 100000--                                                              -Monitor for what object ' s access to the child latch at-- -Particular address was Taken. For cache buffers Chains---Latch The object means data bloc                                                              K Address (DBA)---of the block accessed in buffer cache.--                                                              -Can translate the 6-byte DBA to rfile#/block#--               -Using dbms_utility or Dba.sql script from TPT scripts----other:-- This script was based on x$ tables instead of v$ tables--as some info required was not Externali Zed to v$.--so need to run this script either as SYS or--need to has relevant x$ proxy VI EWS created----The sampling relies on NESTED LOOP join method and having--X$ksuprlat as the In NER (probed) table. ----If sampling always reports a single latch event even though-many different events (oR parameter values) was expected then-the execution plan used was not right.----the join in E Xec Plan Step 9 must be a NESTED LOOPS join, this is how--the high speed sampling are done.----------------- ------------------------------------------------------------------------------------------ | Id | Operation | Name |  E-rows |  Omem | 1Mem | Used-mem |------------------------------------------------------------------------------------------------------   --- |  1 |                 MERGE JOIN Cartesian |      |       1 |       |          |   |-- |   2 |                 MERGE JOIN Cartesian |      |       1 |       |          |    |--|* 3 | FIXED TABLE Full |      X$ksutm |       1 |       |          |   |-- |    4 |                 BUFFER SORT |      |  1 |  9216 | 9216 |   8192 (0) |--|     5 |                         VIEW     |      |       1 |       |          |   |-- |      6 |                 SORT ORDER by |      |  1 |  2048 | 2048 |   2048 (0) |--|       7 |                 HASH GROUP by |      |       1 |       |          |   |-- |        8 |                 NESTED LOOPS OUTER |      |       1 |       |          |   |-- |         9 |                 NESTED LOOPS |      |       1 |       |          |  |-- |          10 |                 VIEW |      |       1 |       |          |  |-- |           11 |                 CONNECT by without Filtering|        |       |       |          |  |-- |            12 |                 FAST DUAL |      |       1 |       |          |          |--|* 13 | FIXED TABLE Full |      X$ksuprlat |       1 |       |          |         |--|* 14 | Fixed TABLE Fixed INDEX |      X$KSLLW (Ind:2) |       1 |       |          | |-- |  15 |                 BUFFER SORT |      |  1 |  9216 | 9216 |    8192 (0) |--|* 16 | FIXED TABLE Full |      X$ksutm |       1 |       |          |              |-- --------------------------------------------------------------------------------------------------------- If you want-to-drill down-latch child level, include ' name ' in first parameter to latchprof----then can use La.sql (V$latch_parent/v$latch_children) to--maps the LATCH address back to LATCH child#------------- -----------------------------------------------------------------------what includes. Columns to display & Aggregate and also options like latch name filteringdef _lhp_what= "&1" def _lhp_sid= "&2" def _lhp_name= "&3" def _lhp_samples= "&4" COL name for A35 truncatecol latchprof_total_ms HEAD "Held ms" for 999999.999COL Latchprof_pct_total _samples Head "Held%" format 999.99COL Latchprof_avg_ms head "avg hold MS "for 999999.999COL dist_samples head getscol total_samples head heldcol ksllwnam for A40 truncatecol ksllwlbl for A20 TR Uncatecol ObjType for A20 Truncatecol object for A17 WRAP JUST rightcol hmode for A12 truncatecol what for A17 W Rapcol func for A40 truncatebreak on lhp_name SKIP 1DEF _if_ora_10_or_higher= "--" promptprompt – LATCHPROFX 2.02 by Ta Nel poder (http://www.tanelpoder.com) COL latchprof_oraversion new_value _if_ora_10_or_higherset termout offselect DE CODE (SUBSTR (BANNER, INSTR (BANNER, ' Release ') +8,1), 1, ', '--') latchprof_oraversion from V$version WHERE rownum=1; SET termout onwith T1 as (select Hsecs from V$timer), samples as (select/*+ ORDERED use_nl (L.x$ksuprlat) U Se_nl (s.x$ksuse) No_transform_distinct_agg */&_lhp_what &_if_ora_10_or_higher, COUNT (DISTI     NCT gets) Dist_samples, COUNT (*) Total_samples, COUNT (*)/&_lhp_samples total_samples_pct FROM (SELECT/*+ no_merge */1 from DUAL CONNECT to level <= &_lhp_samples) s, (select KSUPRP ID PID, Ksuprsid SID, ksuprlnm NAME, Ksuprlat laddr, KSULAWHR, To_char (ksulawhy, ' xxxxxxxxxxxxxxxx ') ob Ject &_if_ora_10_or_higher, Ksulagts GETS &_if_ora_10_or_higher, Lower (KSU PRLMD) Hmode from X$ksuprlat) L, (SELECT indx, Ksusesqh sq                  Lhash, Ksusesql sqladdr &_if_ora_10_or_higher, KSUSESPH Planhash             &_if_ora_10_or_higher, Ksusesch sqlchild &_if_ora_10_or_higher, Ksusesqi sqlid From X$ksuse) s, (SELECT indx, Ksllwnam func, Ksllwnam, Ksllwlbl Objtyp  E, ksllwlbl from X$KSLLW) w WHERE l.sid like ' &_lhp_sid ' and l.ksulawhr = W.indx        (+) and L.sid =S.indx and (LOWER (l.name) Like LOWER ('%&_lhp_name% ') OR LOWER (Rawtohex (l.laddr)) Like LOWER ('%&_lhp_name% ') GROUP by &_lhp_what ORDER by Total_samples DESC), T2 as (SELECT hsecs FRO M v$timer) SELECT/*+ ORDERED */&_lhp_what, s.total_samples &_if_ora_10_or_higher, S.dist_samples--, s.to tal_samples_pct, S.total_samples/&_lhp_samples * latchprof_pct_total_samples, (t2.hsecs-t1.hsecs) * Ten * s . total_samples/&_lhp_samples Latchprof_total_ms--, s.dist_events &_if_ora_10_or_higher, (T2.hsecs-t1.hse CS) * S.total_samples/dist_samples/&_lhp_samples Latchprof_avg_ms from T1, samples s, T2 WHERE ROW NUM <= 20/col name Clearcol hmode clearcol what clearcol func clearcol objtype CLEAR

Latchprof.sql
------------------------------------------------------------------------------------File Name:latchprof.sql ( Latch Holder Profiler)--purpose:perform high-frequency sampling on v$latchholder--and present a ProFi  Le of latches held by sessions----Author:tanel poder--Copyright: (c) http://www.tanelpoder.com----  Usage: @latchprof <what> <sid> <latch name> < #samples >--@latchprof name 350       100000-monitor all latches SID holding--@latchprof sid,name% Library 1000000  -Monitor which SIDs hold latches with "library" in their name--@latchprof sid,name,laddr% 40d993a0 100000 -Monitor which SIDs hold child latch with address 0x40d993a0--other:--The sampling relies on NESTED LOOP Join method and having--V$latchholder as the inner (probed) table. Note that on 9i--need to run the this script as SYS asIt looks like otherwise--the global USE_NL hint are not propagated down to x$ base tables----Th e join in EXEC plan Step 8 must am a NESTED LOOPS join, this was how--the high speed sampling of changing dat Aset from v$latchholder--are done, otherwise you won't see correct results.------------------------------ ----------------------------------------------------------------------- | Id | Operation | Name |  E-rows |  Omem | 1Mem |   Used-mem |---------------------------------------------------------------------------------------------------|  1 |            MERGE JOIN Cartesian |      |       1 |       |          |   |-- |   2 |            MERGE JOIN Cartesian |      |       1 |       |          |    |--|* 3 | FIXED TABLE Full |      X$ksutm |       1 |       |          |   |-- |    4 |            BUFFER SORT |      |  1 | 9216 | 9216 |   8192 (0) |--|     5 |            VIEW |      |       1 |       |          |   |-- |      6 |            SORT ORDER by |      |  1 |  2048 | 2048 |   2048 (0) |--|       7 |            SORT GROUP by |      |  1 |  9216 | 9216 |   8192 (0) |--|        8 |            NESTED LOOPS |      |       1 |       |          |   |-- |         9 |            VIEW |      |       1 |       |          |  |-- |          10 |            CONNECT by without Filtering|        |       |       |          |  |-- |           11 |            FAST DUAL |      |       1 |       |          |         |--|* 12 | FIXED TABLE Full |      X$ksuprlat |       1 |       |          |  |-- |   13 |            BUFFER SORT |      |  1 |  9216 | 9216 |    8192 (0) |--|* 14 | FIXED TABLE Full |      X$ksutm |       1 |       |        |  |-----------------------------------------------------------------------------------------------------If              You want-to-drill down-latch child level, include ' laddr ' in first parameter--to latchprof---- Then you can use La.sql (v$latch_parent/v$latch_children) to--map the LATCH address back to LATCH child# If needed------------------------------------------------------------------------------------what includes Columns to display & aggregate and also options like latch name filteringdef _lhp_what= "&1" DEF _lhp_sid= "&2" DE F _lhp_name= "&3" DEF _lhp_samples= "&4" col name for A35 TRUNCATE Col latchprof_total_ms HEAD "Held MS" for 999999.99 9COL latchprof_pct_total_samples Head "Held%" format 999.99COL Latchprof_avg_ms Head "avg hold MS" for 999.999COL Dist_sa Mples head Getscol total_samples head heldbreak on lhp_name SKIP 1DEF _if_ora_10_or_higher= "--" promptprompt--LatchProf 2 . Tanel Poder (http://www.tanelpoder.com) COL latchprof_oraversion new_value _if_ora_10_or_higherset termout offselect DECODE (SUBSTR, INSTR (BANNER, ' Release ') +8,1), 1, ', '--') latchprof_oraversion from V$version WHERE rownum=1; SET termout onwith T1 as (select Hsecs from V$timer), samples as (select/*+ ORDERED use_nl (L) use_nl (s) US E_nl (L.gv$latchholder.x$ksuprlat) No_transform_distinct_agg */&_lhp_what &_if_ora_10_or_high ER, COUNT (DISTINCT gets) dist_samples, COUNT (*) Total_samples, COUNT (*)/&am P;_lhp_samples total_samples_pct from (SELECT/*+ No_merge */1 from DUAL CONNECT by level <= &am                                     P;_lhp_samples) s, V$latchholder L, (SELECT SID                             Indx, Sql_hash_value Sqlhash, sql_address Sqladdr &_if_ora_10_or_hIgher, Sql_child_number sqlchild &_if_ora_10_or_higher, sql_id sqlid from V  $session) s WHERE l.sid like ' &_lhp_sid ' and (LOWER (l.name) Like LOWER ('%&_lhp_name% ') OR LOWER (Rawtohex (l.laddr)) Like LOWER ('%&_lhp_name% ')) and L.sid = S.indx GROUP by &_lhp_w Hat ORDER by Total_samples DESC), T2 as (select Hsecs from V$timer) Select/*+ ORDERED */& _lhp_what, S.total_samples &_if_ora_10_or_higher, S.dist_samples--, s.total_samples_pct, S.total_samples/& Amp;_lhp_samples * latchprof_pct_total_samples, (t2.hsecs-t1.hsecs) * S.total_samples/&_lhp_samples LAT Chprof_total_ms--S.dist_events, &_if_ora_10_or_higher, (t2.hsecs-t1.hsecs) * S.total_samples/dist_samp Les/&_lhp_samples Latchprof_avg_ms from T1, samples s, T2 WHERE ROWNUM <= 30/col name CLEAR

Reprint Please indicate the source, otherwise be held responsible

Latch:shared Pool Latch:library Cache Diagnostic script (latchprofx.sql,latchprof.sql)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.