[20230123]完善curheapz.sql指令碼.txt
[20230123]完善curheapz.sql指令碼.txt
--//我發現tpt的curheaps.sql指令碼在第2個輸入%的情況下無法控制display last child cursor heap0,heap4,heap6 message using x$ksmhp.
--//而且指令碼查詢hash_value,不支援sql_id,修改一下,並且增加引數&3 => desc asc,控制查詢子游標還是父遊標.
--//desc 查詢子游標 asc 查詢父遊標. 如果出現多了子游標,中間的無法查詢.
--//重新命名為curheapz.sql
$ cat curheapz.sql
-- Copyright 2018 Tanel Poder. All rights reserved. More info at
-- Licensed under the Apache License, Version 2.0. See LICENSE.txt for terms & conditions.
--------------------------------------------------------------------------------
--
-- File name: curheaps.sql
-- Purpose: Show main cursor data block heap sizes and their contents
-- (heap0 and heap6)
--
-- Author: Tanel Poder
-- Copyright: (c)
--
-- Usage: @curheaps <hash_value> <child#>
--
-- @curheaps 942515969 % -- shows a summary of cursor heaps
-- @curheaps 942515969 0 -- shows detail for child cursor 0
--
--
-- @curheapz 4xamnunv51w9j 0 -- query sql_id
-- @curheapz 0 942515969 -- query hash
-- @curheapz 4xamnunv51w9j 942515969 -- query sql_id or hash
--
-- display last child cursor heap0,heap4,heap6 message using x$ksmhp
--
-- Other: "Child" cursor# 65535 is actually the parent cursor
--
--------------------------------------------------------------------------------
col curheaps_size0 heading SIZE0 for 9999999
col curheaps_size1 heading SIZE1 for 9999999
col curheaps_size2 heading SIZE2 for 9999999
col curheaps_size3 heading SIZE3 for 9999999
col curheaps_size4 heading SIZE4 for 9999999
col curheaps_size5 heading SIZE5 for 9999999
col curheaps_size6 heading SIZE6 for 9999999
col curheaps_size7 heading SIZE7 for 9999999
col KGLOBHD0 new_value v_curheaps_kglobhd0 print
col KGLOBHD1 new_value v_curheaps_kglobhd1 noprint
col KGLOBHD2 new_value v_curheaps_kglobhd2 noprint
col KGLOBHD3 new_value v_curheaps_kglobhd3 noprint
col KGLOBHD4 new_value v_curheaps_kglobhd4 print
col KGLOBHD5 new_value v_curheaps_kglobhd5 noprint
col KGLOBHD6 new_value v_curheaps_kglobhd6 print
col KGLOBHD7 new_value v_curheaps_kglobhd7 noprint
set termout off
column v_sort new_value v_sort
select decode(lower('&3'),'p','asc','parent','asc','c','desc','child','desc',lower('&3')) v_sort from dual;
set termout on
select /*+ USE_CONCAT(@"SEL$1" 8 OR_PREDICATES(1)) */
KGLNAHSH,
KGLHDPAR,
kglobt03 SQL_ID,
kglobt09 CHILD#,
KGLHDADR,
KGLOBHD0, KGLOBHS0 curheaps_size0,
KGLOBHD1, KGLOBHS1 curheaps_size1,
KGLOBHD2, KGLOBHS2 curheaps_size2,
KGLOBHD3, KGLOBHS3 curheaps_size3,
KGLOBHD4, KGLOBHS4 curheaps_size4,
KGLOBHD5, KGLOBHS5 curheaps_size5,
KGLOBHD6, KGLOBHS6 curheaps_size6,
KGLOBHD7, KGLOBHS7 curheaps_size7,
-- KGLOBT00 CTXSTAT,
KGLOBSTA STATUS
from
X$KGLOB
-- X$KGLCURSOR_CHILD
where
KGLOBT03 = '&1' or KGLNAHSH= &2
--and KGLNAHSH in (&1)
--and KGLOBT09 like ('&2')
order by
KGLOBT09 &&v_sort
/
-- Cursor data block summary
select
'HEAP0' heap
, ksmchcls class
, ksmchcom alloc_comment
, sum(ksmchsiz) bytes
, count(*) chunks
from
x$ksmhp
where
KSMCHDS = hextoraw('&v_curheaps_kglobhd0')
group by
'HEAP0'
, ksmchcls
, ksmchcom
order by
sum(ksmchsiz) desc
/
select
'HEAP4' heap
, ksmchcls class
, ksmchcom alloc_comment
, sum(ksmchsiz) bytes
, count(*) chunks
from
x$ksmhp
where
KSMCHDS = hextoraw('&v_curheaps_kglobhd4')
group by
'HEAP4'
, ksmchcls
, ksmchcom
order by
sum(ksmchsiz) desc
/
select
'HEAP6' heap
, ksmchcls class
, ksmchcom alloc_comment
, sum(ksmchsiz) bytes
, count(*) chunks
from
x$ksmhp
where
KSMCHDS = hextoraw('&v_curheaps_kglobhd6')
group by
'HEAP6'
, ksmchcls
, ksmchcom
order by
sum(ksmchsiz) desc
/
-- Cursor data block details
-- select * from x$ksmhp where KSMCHDS = hextoraw('&v_curheaps_kglobhd0');
-- select * from x$ksmhp where KSMCHDS = hextoraw('&v_curheaps_kglobhd6');
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2933830/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20210506]完善tix指令碼.txt指令碼
- [20201202]完善sosi指令碼.txt指令碼
- [20210623]完善清除aud指令碼.txt指令碼
- [20231117]完善ashtt.sql指令碼.txtSQL指令碼
- [20211230]完善sql_id指令碼.txtSQL指令碼
- [20211122]完善descx.sql指令碼.txtSQL指令碼
- [20221012]完善spsw.sql指令碼.txtSQL指令碼
- [20221010]完善descz.sql指令碼.txtSQL指令碼
- [20221101]完善descz.sql指令碼.txtSQL指令碼
- [20221101]完善gts.sql指令碼.txtSQL指令碼
- [20230203]完善awr.sql指令碼.txtSQL指令碼
- [20210407]完善ti.sql指令碼.txtSQL指令碼
- [20210125]完善hide.sql指令碼.txtIDESQL指令碼
- [20191111]完善bind_cap.sql指令碼.txtSQL指令碼
- [20220217]完善tpt gts.sql指令碼.txtSQL指令碼
- [20220510]完善tpt expandz.sql指令碼.txtSQL指令碼
- [20211202]完善d_buffer.sql指令碼.txtSQL指令碼
- [20211129]完善tpt tablist.sql指令碼.txtSQL指令碼
- [20211130]完善tpt t.sql指令碼.txtSQL指令碼
- [20211129]完善tpt killi.sql指令碼.txtSQL指令碼
- [20211126]完善tpt pr.sql指令碼.txtSQL指令碼
- [20230414]完善seg2.sql指令碼.txtSQL指令碼
- [20230210]建立完善swcnm.sql指令碼.txtSQL指令碼
- [20221208]完善bind_cap.sql指令碼.txtSQL指令碼
- [20220311]完善ash_wait_chains指令碼.txtAI指令碼
- [20220309]完善shp4.sql指令碼.txtSQL指令碼
- [20231025]完善tpt的trans.sql指令碼.txtSQL指令碼
- [20241114]建立完善ext_kglob.sh指令碼.txt指令碼
- [20220111]完善tpt ashash_index_helper指令碼.txtIndex指令碼
- [20220323]完善tpt get_trace.sql指令碼.txtSQL指令碼
- [20220823]完善tpt的ashtop.sql指令碼.txtSQL指令碼
- [20221208]完善bind_cap_awr.sql指令碼.txtSQL指令碼
- [20190416]完善shared latch測試指令碼2.txt指令碼
- [20220129]完善tpt ash ash_index_helperx指令碼.txtIndex指令碼
- [20211111]補充完善ash_wait_chains指令碼.txtAI指令碼
- [20230302]建立完善tpt o2.sql指令碼.txtSQL指令碼
- [20230203]建立完善sp1x.sql指令碼.txtSQL指令碼
- [20220519]完善tpt dash_wait_chains2.sql指令碼.txtAISQL指令碼