Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
235 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
with v as ( | ||
select--+ leading(db sn st) use_nl(sn) use_nl(st) no_merge | ||
st.snap_id | ||
,sn.begin_interval_time as beg_time | ||
,to_char(begin_interval_time,'fmday') as wd | ||
,st.stat_name | ||
,st.value - lag(value) over(partition by stat_name order by sn.snap_id) as value | ||
,lag(sn.snap_id) over(partition by stat_name order by sn.snap_id) as prev_snap | ||
from | ||
v$database db | ||
,dba_hist_snapshot sn | ||
,dba_hist_sysstat st | ||
where st.stat_name in ( | ||
'CPU used by this session' | ||
,'user I/O wait time' | ||
,'DB time' | ||
-- ,'table scan rows gotten' | ||
-- ,'rows fetched via callback' | ||
-- ,'table fetch by rowid' | ||
-- ,'table fetch continued row' | ||
-- ,'index fetch by key' | ||
) | ||
and db.DBID = st.dbid | ||
and st.snap_id = sn.snap_id | ||
and sn.dbid = db.dbid | ||
and sn.end_interval_time>trunc(sysdate)-365 | ||
) | ||
,v2 as ( | ||
select snap_id,beg_time,wd,stat_name,value,prev_snap | ||
,ntile(20) over(partition by stat_name order by value) nt | ||
from v | ||
where value > 0 | ||
and prev_snap + 1 = snap_id | ||
and extract( hour from beg_time) in (10,11,12) | ||
and wd not in ('saturday','sunday') | ||
) | ||
,v3 as ( | ||
select snap_id,beg_time,wd,stat_name,value,prev_snap | ||
from v2 | ||
where snap_id not in ( select snap_id | ||
from v2 | ||
group by snap_id | ||
having sum(decode(nt,1,1,20,1))>=2 | ||
) | ||
) | ||
select | ||
snap_id | ||
,to_char(beg_time,'yyyy-mm-dd hh24:mi') beg_time | ||
,wd | ||
,to_char(cpu_time ,'fm999999999999') cpu_time | ||
,to_char(io_time ,'fm999999999999') io_time | ||
,to_char(db_time ,'fm999999999999') db_time | ||
-- ,to_char(fts_rows ,'999g999g999999') fts_rows | ||
-- ,to_char(fetches_callback ,'999g999g999999') fetches_callback | ||
-- ,to_char(fetches_rowid ,'999g999g999999') fetches_rowid | ||
-- ,to_char(fetches_continued ,'999g999g999999') fetches_continued | ||
-- ,to_char(fetches_index_by_key ,'999g999g999999') fetches_index_by_key | ||
,to_char(round(cpu_time *100/max(cpu_time )over(),2),'999.00') pct_cpu_time | ||
,to_char(round(io_time *100/max(io_time )over(),2),'999.00') pct_io_time | ||
,to_char(round(db_time *100/max(db_time )over(),2),'999.00') pct_db_time | ||
-- ,to_char(round(fts_rows *100/max(fts_rows )over(),2),'999.00') pct_fts_rows | ||
-- ,to_char(round(fetches_callback *100/max(fetches_callback )over(),2),'999.00') pct_fetches_callback | ||
-- ,to_char(round(fetches_rowid *100/max(fetches_rowid )over(),2),'999.00') pct_fetches_rowid | ||
-- ,to_char(round(fetches_continued *100/max(fetches_continued )over(),2),'999.00') pct_fetches_continued | ||
-- ,to_char(round(fetches_index_by_key*100/max(fetches_index_by_key)over(),2),'999.00') pct_fetches_index_by_key | ||
from v3 | ||
pivot( | ||
max(value) | ||
for stat_name in ( | ||
'CPU used by this session' cpu_time | ||
,'user I/O wait time' io_time | ||
,'DB time' db_time | ||
-- ,'table scan rows gotten' fts_rows | ||
-- ,'rows fetched via callback' fetches_callback | ||
-- ,'table fetch by rowid' fetches_rowid | ||
-- ,'table fetch continued row' fetches_continued | ||
-- ,'index fetch by key' fetches_index_by_key | ||
) | ||
) | ||
order by 1 | ||
/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,43 @@ | ||
@inc/input_vars_init; | ||
|
||
col OWNER format a30; | ||
col NAME format a30; | ||
col OBJECT_NAME format a50; | ||
col TYPE format a12; | ||
col REFERENCED_OWNER format a30 heading REF_OWNER; | ||
col REFERENCED_NAME format a30 heading REF_NAME; | ||
col REFERENCED_TYPE format a12 heading REF_TYPE; | ||
col REFERENCED_LINK_NAME format a10 heading REF_LINK; | ||
col REF_OWNER format a30 heading REF_OWNER; | ||
col REF_NAME format a30 heading REF_NAME; | ||
col REF_TYPE format a12 heading REF_TYPE; | ||
col REF_LINK_NAME format a10 heading REF_LINK; | ||
col DEPENDENCY_TYPE format a10; | ||
break on ref_type on ref_owner on ref_name on object_name; | ||
|
||
prompt Dependencies list: | ||
|
||
select * | ||
select | ||
connect_by_root referenced_type as ref_type | ||
,connect_by_root referenced_owner as ref_owner | ||
,connect_by_root referenced_name as ref_name | ||
,rpad(' ',level*2,'..')||dd.OWNER||'.'||dd.NAME as object_name | ||
,dd.type | ||
,(select o.CREATED from dba_objects o where o.OWNER = dd.OWNER and o.object_type = dd.type and o.object_name = dd.name) CREATED | ||
,(select o.LAST_DDL_TIME from dba_objects o where o.OWNER = dd.OWNER and o.object_type = dd.type and o.object_name = dd.name) LAST_DDL_TIME | ||
,(select o.status from dba_objects o where o.OWNER = dd.OWNER and o.object_type = dd.type and o.object_name = dd.name) obj_status | ||
from dba_dependencies dd | ||
where dd.referenced_owner like nvl(upper('&2'),'%') | ||
and dd.referenced_name=upper('&1'); | ||
start with | ||
dd.referenced_owner like nvl(upper('&2'),'%') | ||
and dd.referenced_name = upper('&1') | ||
and dd.referenced_link_name is null | ||
connect by level<=3 | ||
and dd.referenced_owner = prior dd.OWNER | ||
and dd.referenced_name = prior dd.NAME | ||
and dd.REFERENCED_TYPE = prior dd.TYPE | ||
and dd.REFERENCED_LINK_NAME is null | ||
; | ||
|
||
col OWNER clear; | ||
col NAME clear; | ||
col OBJECT_NAME clear; | ||
col TYPE clear; | ||
col REFERENCED_OWNER clear; | ||
col REFERENCED_NAME clear; | ||
col REFERENCED_TYPE clear; | ||
col REFERENCED_LINK_NAME clear; | ||
col REF_OWNER clear; | ||
col REF_NAME clear; | ||
col REF_TYPE clear; | ||
col REF_LINK_NAME clear; | ||
col DEPENDENCY_TYPE clear; | ||
|
||
clear break; | ||
@inc/input_vars_undef; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
var c clob | ||
accept _query prompt "Enter query: "; | ||
exec dbms_sql2.expand_sql_text(q'[&_query]',:c); | ||
print :c; | ||
undef _query; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
alter session set events '22829 trace name context off'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
alter session set events '22829 trace name context forever'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
exec DBMS_RESULT_CACHE.BYPASS (false); | ||
select DBMS_RESULT_CACHE.STATUS from dual; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
exec DBMS_RESULT_CACHE.BYPASS (true); | ||
select DBMS_RESULT_CACHE.STATUS from dual; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
col "DBMS_RESULT_CACHE.STATUS" format a50; | ||
select DBMS_RESULT_CACHE.STATUS "DBMS_RESULT_CACHE.STATUS" from dual; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
@inc/input_vars_init; | ||
prompt *** Show top session by undo used: | ||
prompt; | ||
col username format a25; | ||
col osuser format a25; | ||
col process format a13; | ||
col object format a40; | ||
col subobject_name format a30; | ||
col object_type format a20; | ||
with t as ( | ||
select * | ||
from (select * | ||
from v$transaction | ||
where used_ublk>0 | ||
order by used_ublk desc) | ||
where rownum<=10 | ||
) | ||
select | ||
s.sid | ||
,s.serial# | ||
,s.username | ||
,s.osuser | ||
,t.used_urec as recs | ||
,t.used_ublk as blocks | ||
,o.owner||'.'||o.object_name object | ||
,o.subobject_name | ||
,o.data_object_id | ||
,o.object_type | ||
,l.object_id | ||
,l.xidusn | ||
,l.xidslot | ||
,l.xidsqn | ||
,l.process | ||
from t | ||
, v$session s | ||
, v$locked_object l | ||
, dba_objects o | ||
where t.addr = s.taddr | ||
and t.xidusn = l.xidusn(+) | ||
and t.xidslot = l.xidslot(+) | ||
and l.object_id = o.object_id(+) | ||
order by blocks desc,sid | ||
/ | ||
col username clear; | ||
col osuser clear; | ||
col process clear; | ||
col object clear; | ||
col subobject_name clear; | ||
col object_type clear; | ||
@inc/input_vars_undef; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
@inc/input_vars_init; | ||
prompt *** Show undo used by SID. | ||
prompt Usage: @undo_used sid | ||
|
||
col username format a25; | ||
col osuser format a25; | ||
col process format a13; | ||
col object format a40; | ||
col subobject_name format a30; | ||
col object_type format a20; | ||
select | ||
s.sid | ||
,s.serial# | ||
,s.username | ||
,s.osuser | ||
,t.used_urec as recs | ||
,t.used_ublk as blocks | ||
,o.owner||'.'||o.object_name object | ||
,o.subobject_name | ||
,o.data_object_id | ||
,o.object_type | ||
,l.object_id | ||
,l.xidusn | ||
,l.xidslot | ||
,l.xidsqn | ||
,l.process | ||
from v$transaction t | ||
, v$session s | ||
, v$locked_object l | ||
, dba_objects o | ||
where t.addr = s.taddr | ||
and t.xidusn = l.xidusn(+) | ||
and t.xidslot = l.xidslot(+) | ||
and l.object_id = o.object_id(+) | ||
and sid = '&1'+0 | ||
/ | ||
col username clear; | ||
col osuser clear; | ||
col process clear; | ||
col object clear; | ||
col subobject_name clear; | ||
col object_type clear; | ||
@inc/input_vars_undef; |