[20230203]完善awr.sql指令碼.txt
[20230203]完善awr.sql指令碼.txt
--//來自WRH$_ACTIVE_SESSION_HISTORY Does Not Get Purged Based Upon the Retention Policy.
--//主要原因是執行很慢,如果WRH$_ACTIVE_SESSION_HISTORY表很大的情況下.
--//自己改寫如下:
set serveroutput on
declare
CURSOR cur_part IS
SELECT partition_name from dba_tab_partitions
WHERE table_name = 'WRH$_ACTIVE_SESSION_HISTORY';
query1 varchar2(200);
query2 varchar2(200);
&&1 TYPE partrec IS RECORD (snapid number, dbid number);
&&2 TYPE partrec IS RECORD (snapid number);
TYPE partlist IS TABLE OF partrec;
Outlist partlist;
begin
&&1 dbms_output.put_line('PARTITION NAME SNAP_ID DBID');
&&2 dbms_output.put_line('PARTITION NAME SNAP_ID ');
dbms_output.put_line('--------------------------- ------------------');
for part in cur_part loop
&&1 query1 := 'select min(snap_id), dbid from sys.WRH$_ACTIVE_SESSION_HISTORY partition ('||part.partition_name||') group by dbid';
&&2 query1 := 'select min(snap_id) from sys.WRH$_ACTIVE_SESSION_HISTORY partition ('||part.partition_name||')';
execute immediate query1 bulk collect into OutList;
if OutList.count > 0 then
for i in OutList.first..OutList.last loop
&&1 dbms_output.put_line(part.partition_name||' Min '||OutList(i).snapid||' '||OutList(i).dbid);
&&2 dbms_output.put_line(part.partition_name||' Min '||OutList(i).snapid);
end loop;
end if;
&&1 query2 := 'select max(snap_id), dbid from sys.WRH$_ACTIVE_SESSION_HISTORY partition ('||part.partition_name||') group by dbid';
&&2 query2 := 'select max(snap_id) from sys.WRH$_ACTIVE_SESSION_HISTORY partition ('||part.partition_name||')';
execute immediate query2 bulk collect into OutList;
if OutList.count > 0 then
for i in OutList.first..OutList.last loop
&&1 dbms_output.put_line(part.partition_name||' Max '||OutList(i).snapid||' '||OutList(i).dbid);
&&2 dbms_output.put_line(part.partition_name||' Max '||OutList(i).snapid);
dbms_output.put_line('---');
end loop;
end if;
end loop;
end;
/
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2934654/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20230203]建立完善sp1x.sql指令碼.txtSQL指令碼
- [20170628]完善ooerr指令碼.txt指令碼
- [20210506]完善tix指令碼.txt指令碼
- [20210407]完善ti.sql指令碼.txtSQL指令碼
- [20210623]完善清除aud指令碼.txt指令碼
- [20201202]完善sosi指令碼.txt指令碼
- [20220510]完善tpt expandz.sql指令碼.txtSQL指令碼
- [20211230]完善sql_id指令碼.txtSQL指令碼
- [20221010]完善descz.sql指令碼.txtSQL指令碼
- [20221101]完善descz.sql指令碼.txtSQL指令碼
- [20221101]完善gts.sql指令碼.txtSQL指令碼
- [20211130]完善tpt t.sql指令碼.txtSQL指令碼
- [20211122]完善descx.sql指令碼.txtSQL指令碼
- [20230414]完善seg2.sql指令碼.txtSQL指令碼
- [20231117]完善ashtt.sql指令碼.txtSQL指令碼
- [20221012]完善spsw.sql指令碼.txtSQL指令碼
- [20221208]完善bind_cap.sql指令碼.txtSQL指令碼
- [20211129]完善tpt tablist.sql指令碼.txtSQL指令碼
- [20211202]完善d_buffer.sql指令碼.txtSQL指令碼
- [20211129]完善tpt killi.sql指令碼.txtSQL指令碼
- [20220323]完善tpt get_trace.sql指令碼.txtSQL指令碼
- [20220309]完善shp4.sql指令碼.txtSQL指令碼
- [20220217]完善tpt gts.sql指令碼.txtSQL指令碼
- [20230210]建立完善swcnm.sql指令碼.txtSQL指令碼
- [20230123]完善curheapz.sql指令碼.txtSQL指令碼
- [20210125]完善hide.sql指令碼.txtIDESQL指令碼
- [20241114]建立完善ext_kglob.sh指令碼.txt指令碼
- [20190416]完善shared latch測試指令碼2.txt指令碼
- [20220823]完善tpt的ashtop.sql指令碼.txtSQL指令碼
- [20231025]完善tpt的trans.sql指令碼.txtSQL指令碼
- [20221208]完善bind_cap_awr.sql指令碼.txtSQL指令碼
- [20211126]完善tpt pr.sql指令碼.txtSQL指令碼
- [20191111]完善bind_cap.sql指令碼.txtSQL指令碼
- [20220311]完善ash_wait_chains指令碼.txtAI指令碼
- [20230302]建立完善tpt o2.sql指令碼.txtSQL指令碼
- [20220422]完善tpt ash ash_index_helperx指令碼2.txtIndex指令碼
- [20220111]完善tpt ashash_index_helper指令碼.txtIndex指令碼
- [20220317]補充完善TPT 顯示欄位列的指令碼.txt指令碼