-- Code Depot -- Oracle Tuning Power Scripts -- With 100+ High Performance SQL Scripts -- ISBN 0-9744486-7-2

-- ****************************************************** -- ******************************************************

---------rem rem rem rem

CPU_TIME.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. Use at your own risk. To license this script for a commercial purpose, contact info@rampant.cc ************************************************* CPU_TIME.SQL Mike Ault heading 'Statistic' heading 'Value'

col name col value

ttitle 'CPU Related Statistics' spool cpu_stats select name,value from v$sysstat where upper(name) like '%CPU%' ; spool off clear columns ttitle off

----------

CPU.SQL ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. Use at your own risk. To license this script for a commercial purpose, contact info@rampant.cc ************************************************* CPU.SQL Mike Ault SQL by CPU Usage (v$sqlarea) sql_text format a40 word_wrapped heading 'SQL Text' cpu_time heading 'CPU Time'

rem rem rem rem rem rem column column

column elapsed_time heading 'Elapsed Time' column disk_reads heading 'Disk Reads' column buffer_gets heading 'Buffer Gets' column rows_processed heading 'Rows Processed' set pages 55 lines 132 ttitle 'SQL By CPU Usage' spool cpu select * from (select sql_text, cpu_time/1000000000 cpu_time, elapsed_time/1000000000 elapsed_time, disk_reads, buffer_gets, rows_processed from v$sqlarea order by cpu_time desc, disk_reads desc ) where rownum < 21 / spool off set pages 22 lines 80 ttitle off

----------

ENQUEUES9i.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. Use at your own risk. To license this script for a commercial purpose, contact info@rampant.cc *************************************************

rem rem ENQUEUES9i.SQL rem Mike Ault rem ttitle 'Enqueues Report' spool enqueues prompt Enqueues col name format a25 col lock format a4 heading 'Lock' col gets format 9,999,999 heading 'Gets' col waits format 9,999,999 heading 'Waits' col Mode format a4 SELECT * FROM v$sysstat WHERE class=4 ; SELECT chr(bitand(p1,-16777216)/16777215) chr(bitand(p1, 16711680)/65535) "Lock", to_char( bitand(p1, 65535) ) "Mode" FROM v$session_wait WHERE event = 'enqueue' /

Prompt Enqueue Stats select * from v$enqueue_stat where cum_wait_time>0 order by cum_wait_time desc / spool off ttitle off

----------

events.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. Use at your own risk. To license this script for a commercial purpose, contact info@rampant.cc ************************************************* sid event total_waits total_timeouts time_waited average_wait username HEADING HEADING HEADING HEADING HEADING HEADING HEADING Sid Event Total Waits Total Timeouts Time Waited Average Wait User FORMAT a40

COLUMN COLUMN COLUMN COLUMN COLUMN COLUMN COLUMN

BREAK ON username ttitle "Session Events By User" SPOOL events SET LINES 132 PAGES 59 VERIFY OFF FEEDBACK OFF SELECT username, event, total_waits,total_timeouts, time_waited,average_wait FROM sys.v_$session_event a, sys.v_$session b WHERE a.sid= b.sid ORDER BY 1; SPOOL OFF PAUSE Press Enter to continue CLEAR COLUMNS CLEAR BREAKS SET LINES 80 PAGES 22 VERIFY ON FEEDBACK ON TTITLE OFF €

-SYS_EVENTS_PCT.sql -- ************************************************* -- Copyright © 2005 by Rampant TechPress

------rem rem rem rem rem rem rem rem col col col col col col col col col This script is free for non-commercial purposes with no warranties.SQL Mike Ault This report shows the major events in the database and their contribution to overall response time.'dispatcher timer') .999 heading total_time new_value divide_by noprint value new_value val €€noprint percent format 999. value time_waited. Use at your own risk.990 heading duration new_value millisec noprint p_of_total heading 'Percent of Total 'Event Name' 'Total Waits' 'Average Waits' 'Time Waited' 'Percent Of Non-Idle Waits' Uptime' format 999. 'virtual circuit status'. ttitle 'System Events Percent' break on report compute sum of time_waited on report spool sys_events select name event.cc ************************************************* SYS_EVENTS_PCT.999. contact info@rampant. value/(&&divide_by+&&val)*100 Percent.999 heading average_wait format 999.999 heading time_waited format 999. event format a30 heading waits format 999. 0 average_wait.'ges remote message'. To license this script for a commercial purpose.999. select sum(time_waited) total_time from v$system_event where total_waits-total_timeouts>0 and event not like 'SQL*Net%' and event not like 'smon%' and event not like 'pmon%' and event not like 'rdbms%' and event not like 'PX%' and event not like 'sbt%' and event not in ('gcs remote message'. 0 waits. value/&&millisec*100 p_of_total from v$sysstat where name ='CPU used when call started' .9999 set lines 132 feedback off verify off pages 50 select to_number(sysdate-startup_time)*86400*1000 duration from v$instance .999. select value from v$sysstat where name ='CPU used when call started' .

cc ************************************************* rem rem SYS_EVENTS.'dispatcher timer') and time_waited > 0 order by percent desc . To license this script for a commercial purpose.999. Use at your own risk. spool off clear columns ttitle off clear computes clear breaks ---------- SYS_EVENTS. time_waited from v$system_event where total_waits-total_timeouts>0 .sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. time_waited/(total_waits-total_timeouts) average_wait.999. contact info@rampant. time_waited/(&&divide_by+&&val)*100 Percent. time_waited/(total_waits-total_timeouts) average_wait.999 heading col average_wait format 999. total_waits-total_timeouts waits. time_waited.SQL rem Mike Ault rem set pagesize 100 col event format a30 heading col waits format 999. total_waits-total_timeouts waits.999 heading ttitle 'System Events' break on report compute sum of time_waited on report spool sys_events 'Event Name' 'Total Waits' 'Average Waits' 'Time Waited' select event. time_waited/&&millisec*100 P_of_total from v$system_event where total_waits-total_timeouts > 0 and event not like 'SQL*Net%' and event not like 'smon%' and event not like 'pmon%' and event not like 'rdbms%' and event not like 'PX%' and event not like 'sbt%' and event not in ('gcs remote message'.union select event.999.999 heading col time_waited format 999. 'virtual circuit status'.'ges remote message'.

spool off clear columns ttitle off . kghlunfs from sys.event not like 'SQL*Net%' event not like 'smon%' event not like 'pmon%' event not like 'rdbms%' event not like '%control%' event not like 'LGWR%' and event not like 'PX%' order by time_waited desc / spool off clear columns ttitle off and and and and and and --------rem rem rem rem ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.SQL Mike Ault kghlurcr kghlutrn kghlufsh kghluops kghlunfu kghlunfs heading heading heading heading heading heading "RECURRENT CHUNKS" "TRANSIENT CHUNKS" "FLUSHED CHUNKS" "PINS AND RELEASES" "ORA-4031 ERRORS" "LAST ERROR SIZE" column column column column column column ttitle 'Report on 4031 events (SYS user only)' spool cpu_stats select kghlurcr. kghluops. kghlufsh. contact info@rampant.cc ************************************************* SEE_4031. Use at your own risk. To license this script for a commercial purpose. kghlunfu.x$kghlu where inst_id = userenv('Instance') . kghlutrn.

total_waits-a.total_waits-b.time_waited_micro-a. contact info@rampant. rem rem Total seconds of waiting (total_time->divide_by) rem in 9.'ges remote message'. so we divide by 1000000 to get to rem seconds rem select sum(b.time_waited_micro)/1000000 total_time from stats$system_event a.event not like 'PX%' and a. stats$system_event b where (b.0 this was in microseconds. v$parameter b where b.sql rem rem Function: Calculates the delta values between statspacks for events rem then shows what they contribute to the overall wait picture rem rem total response time=wait time+cpu time (divide_by+val) rem ttitle off col event format a30 heading 'Event Name' col waits format 999.999.snap_id=&&first_snap_id .startup_time)*86400*to_number(b.event not like 'SQL*Net%' and a.999 heading 'Average Waits' col time_waited format 999.999 heading 'Total Waits' col average_wait format 999.event not like 'smon%' and a. To license this script for a commercial purpose.event not like 'pmon%' and a.'dispatcher timer') and a.event not like 'sbt%' and a.event not in ('gcs remote message'. 'virtual circuit status'.--------- ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.999 heading 'Time Waited' col percent format 999.cc ************************************************* rem rem Mike Ault rem rem snap_delta_sys_events_pct90.total_timeouts)-(a. Use at your own risk.990 heading 'Percent Of Non-Idle Waits' col p_of_total format 999. total available time is elapsed*number of cpus rem select to_number(sysdate-a.999.999.event not like 'rdbms%' and a.9999 heading 'Percent of Total Uptime' rem rem col total_time new_value divide_by noprint col value new_value val noprint col duration new_value sec noprint rem set lines 132 feedback off verify off pages 50 rem rem Number of seconds since startup (duration->sec) rem 86400 is number of seconds in a day.name='cpu_count'.value) duration from v$instance a.total_timeouts)>0 and a.

((b.time_waited_micro)/1000000)/((b.time_waited_micro)/1000000 time_waited.time_waited_micro-a.total_waits-b.snap_id=&&sec_snap_id and a.total_timeouts)>0 and a.total_timeouts) waits.time_waited_micro)/1000000/(&&divide_by+&&val))*1 00 Percent.total_timeouts)) average_wait. 'virtual circuit status'.total_waits-b. (&&val/1000/(&&sec))*100 p_of_total from dual union select a. first we get CPU contribution.snap_id=&&sec_snap_id.'ges remote message'. rem rem CPU seconds between snap 1 and snap 2 (value->val) rem as placed in table the view they are milliseconds rem divide by 1000 to correct to seconds rem select b. &&val time_waited.total_waits-a. ((b.event.event not like 'PX%' and a.event not like 'pmon%' and a.value/1000 value from stats$sysstat a. then the waits rem select 'CPU used when call started' event.event order by percent desc / spool off clear columns ttitle off clear computes clear breaks undef first_snap_id .name ='CPU used when call started' and a.value-a. stats$sysstat b where a.tota l_timeouts)-(a.time_waited_micro-a. 0 waits.total_waits-a.total_timeouts)-(a.snap_id=&&first_snap_id and b.event not like 'SQL*Net%' and a.name ='CPU used when call started' and b. (&&val/(&&divide_by+&&val))*100 Percent.time_waited_micro)/1000000)/&&sec)*100 P_of_tota l from stats$system_event a.time_waited_micro-a. 0 average_wait.total_timeouts)-(a.total_waits-b.event not in ('gcs remote message'. (b.event=b.total_waits-a.event not like 'rdbms%' and a.event not like 'sbt%' and a.event not like 'smon%' and a.event . rem ttitle 'Snap &&first_snap_id to &&sec_snap_id System Events Percent' break on report compute sum of time_waited on report spool snap&&first_snap_id'_to_'&&sec_snap_id'_sys_events' rem rem Now for the report. (((b.event=b.snap_id=&&first_snap_id and b.time_waited_micro>0 and a.and b. (b.time_waited_micro-a.'dispatcher timer') and b. stats$system_event b where (b.snap_id=&&sec_snap_id and a.time_waited_micro-a.

wait_class <> 'Idle' ) pct .time_waited_mic ro.dbid(+) = b. To license this script for a commercial purpose. dba_hist_system_event e where b.snap_id = &pEndSnap and b.total_waits.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.instance_number and b1.instance_number = e. e. (e.wait_class <> 'Idle' order by time desc.time_waited_micro.time_waited_micro .cc ************************************************* select event .snap_id and e1.0) waits .0) and e1. waits "Waits" . Use at your own risk.snap_id(+) = b.dbid and e1.nvl(b.total_waits.total_waits > nvl(b1.0))/100000 0 time .event_name event €€€€€€€€€€€€€€€€€.total_waits > nvl(b.0)) from dba_hist_system_event b1 . (e.time_waited_micro .total_waits.wait_class waitclass from dba_hist_system_event b .dbid(+) = &pDbId and e. e.total_waits .sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.nvl(b.dbid and b1. pct*100 "Percent of Total" . Use at your own risk. dba_hist_system_event e1 where b1.time_waited_micro .undef sec_snap_id ---------- wt_events_int_10g.snap_id = e.instance_number and e1. waits desc ) ------- enq_stat_int_10g.nvl(b.snap_id €€€€€€€€€€€€€€and b1. contact info@rampant.event_id and e1.instance_number(+) = &pInstNum €€€and e.0))/ (select sum(e1.dbid = e.instance_number(+) = b.event_id €€€€€€€€€€€and e. waitclass "Wait Class" from (select e.event_id(+) = e1. time "Wait Time (s)" .dbid = &pDbId €€€and b.snap_id(+) = &pBgnSnap and e.nvl(b1.event_id(+) = e.instance_number = &pInstNum and b.time_waited_micro.0) and e. .

total_req#.eq_type and b.0) waits .dbid and b.cc ************************************************* column "Statistic Name" format A40 . e.nvl(b.0) sreq .total_wait#.instance_number and b. sreq "Successful Gets".req_reason(+) = e.req_reason) .0)) ) ) awttm from dba_hist_enqueue_stat e .snap_id(+) = &pBgnSnap and e.cum_wait_time.To license this script for a commercial purpose.' ')) decode( upper(e.0) freq .total_wait# . Use at your own risk. decode( (e.total_wait#.cum_wait_time . waits desc) ---------- sys_time_model_int_10g.nvl(b. dba_hist_enqueue_stat b .0))/1000 wttm . e.************************************************* select ety Enqueue . to_number(NULL) .succ_req# . 'CONTENTION'. To license this script for a commercial purpose.dbid(+) = &pDbId and e.total_wait# .snap_id = &pEndSnap and b.req_reason and e. '-'.cc -.nvl(b.0)) .dbid(+) = e. v$lock_type l where b. freq "Failed Gets".eq_type €order by wttm desc.total_wait#.failed_req#.contact info@rampant. ' (' e. awttm "Average Wait Time(ms)" from ( select /*+ ordered */ e. null .eq_type(+) = e.-.cum_wait_time.type(+) = e.req_reason ')') ety .name.nvl(b. waits "Waits". reqs "Requests".nvl(b. -.total_wait#.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.nvl(b.0) > 0 and l.failed_req# .nvl(b. ( (e. 0. (e.instance_number = &pInstNum and b.0) reqs .0)) / (e. e.succ_req#.nvl(b.eq_type '-' to_char(nvl(l.total_req# . e.total_wait# . contact info@rampant. null .instance_number(+) = &pInstNum and e.instance_number(+) = e.nvl(b. wttm "Wait Time (s)".dbid = &pDbId and b.cum_wait_time .total_wait# .

b1.dbid €€€€€€€€€€€€€= b.999 column "Percent of Total DB Time" format 999. (e.b.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. total_req#. To license this script for a commercial purpose. contact info@rampant. dba_hist_sys_time_model b1 where b1.instance_number = e.instance_number b.stat_id ) "Percent of Total DB Time" from dba_hist_sys_time_model e .snap_id and b1.dbid and b1.column "Time (s)" format 999.cc ************************************************* begin_interval_time req_reason cum_wait_time total_req# total_wait# failed_req# format a10 format a25 head CUM WAIT TIME head TOTAL REQ# head TOTAL WAIT# head FAILED REQ# column column column column column column select begin_interval_time.snap_id = e.snap_id and e1. decode( e.dbid and e1.999 select e.value . dba_hist_sys_time_model b €where and and and and and and and €order b. req_reason.'DB time' .stat_name.stat_id ---------- ash_enqueues.stat_id e.b.b.instance_number and b1.value > 0 by 2 desc.value).value .value .dbid = e.instance_number = b. . eq_type.snap_id b. to_number(null) .instance_number and e1.value)/1000000 "Time (s)" . = = = = = = = &pBgnSnap &pEndSnap &pDbId &pDbId &pInst_Num &pInst_Num e.snap_id e.stat_name "Statistic Name" .stat_id €= e1. Use at your own risk. 100*(e.value .-1) from dba_hist_sys_time_model e1 .snap_id = b.dbid e.value) )/ ( select nvl((e1.stat_name = 'DB time' and b1.dbid b.instance_number e.

cum_wait_time. Use at your own risk. 'physical reads'.v_$sysstat where name in ('consistent changes'. 'user rollbacks' ) €order by 1. 'physical writes'. ---------- globiostats. value from sys.cc ************************************************* select name. 'user commits'. failed_req#. To license this script for a commercial purpose. succ_req#. contact info@rampant. ---------- buffratio. 'db block changes'.total_wait#. Use at your own risk. contact info@rampant.cc ************************************************* select 100 - . cum_wait_time from dba_hist_enqueue_stat €natural join dba_hist_snapshot where cum_wait_time > 0 order by begin_interval_time. To license this script for a commercial purpose. 'consistent gets'.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. 'db block gets'. 'sorts (disk)'.

€'rdbms ipc message'.1)). contact info@rampant. 'physical reads direct (lob)'.2) pct_timeouts.2) pct_waits. round((average_wait / 100). average_wait_sec from (select event.cc ************************************************* select event. €'smon timer'. value. 'physical reads direct (lob)'. 'physical reads direct'). 'physical reads direct'. total_timeouts.v_$sysstat €where name in ('session logical reads'. round((time_waited / 100). ---------- syswaits. round(100 * (time_wait_sec / greatest(sum_time_waited. Use at your own risk. total_waits.2) average_wait_sec from sys. round(100 * (total_waits / sum_waits). . €'pmon timer'. time_wait_sec. value. 0)) sum (decode (name.100 * (round ((sum (decode (name. 0))) / (sum (decode (name. €'rdbms ipc reply'.v_$system_event where event not in ('lock element cleanup'. 'session logical reads'.3)) hit_ratio €from sys.2) time_wait_sec. 0)) sum (decode (name.2) pct_time_waited. total_waits. total_timeouts. 'physical reads'. value. 1)) ). round(100 * (total_timeouts / greatest(sum_timeouts.1)).sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. 'physical reads'. To license this script for a commercial purpose. value.

sum(round((time_waited / 100). €'SQL*Net more data from client'. 1 asc. €'pipe get'. €'WMON goes to sleep') and €event not like 'DFS%' and €event not like 'KXFX%').Slaves'. (select sum(total_waits) sum_waits. Use at your own risk. €'PL/SQL lock timer'. €'parallel query dequeue wait'.v_$system_event €where event not in €('lock element cleanup'. €'pmon timer'. €'pipe get'. €'parallel query idle wait . €'SQL*Net message from client'. €'SQL*Net message to client'. sum(total_timeouts) sum_timeouts. €'SQL*Net break/reset to client'. €'virtual circuit status'. €'slave wait'. €'SQL*Net message to client'. €'Null event'. €'dispatcher timer'. €'Null event'.Slaves'. €'parallel query idle wait . €'virtual circuit status'. €'SQL*Net more data from client'. €'slave wait'. €'PL/SQL lock timer'. €'WMON goes to sleep') and €event not like 'DFS%' and €event not like 'KXFX%') order by 2 desc. To license this script for a commercial purpose. contact info@rampant.cc ************************************************* . €'parallel query dequeue wait'. €'SQL*Net break/reset to client'. €'dispatcher timer'. ---------rem fileio. €'rdbms ipc reply'.€'SQL*Net message from client'.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. €'rdbms ipc message'. €'smon timer'.2)) sum_time_waited €from sys.

phywrts. sys.phyblkwrt/greatest(a.b.file#.file# order by 1 / spool off set feedback on verify on lines 80 pages 22 .phyrds.phyblkrd/greatest(c.file# union select c.phyrds. a. select &st1+&st2 sum_io from dual.d.phyrds+b.rem NAME: fileio.v_$tempstat b.phywrts)/&divide_by) Percent.sql rem rem FUNCTION: Reports on the file io status of all of the rem datafiles in the database.v_$filestat a.file#=b.file#=d.v_$dbfile b where a.name.v_$tempstat c.phywrts. a.99 heading 'Block Write Ratio' column phyrds heading 'Physical Reads' column phywrts heading 'Physical Writes' column phyblkrd heading 'Physical Block Reads' column phyblkwrt heading 'Physical Block Writes' column name format a30 heading 'File Name' column file# format 9999 heading 'File' column dt new_value today noprint TTITLE 'FILE I/O Status' select to_char(sysdate.0) sum_io1 from sys.phywrts)/&divide_by) Percent. c. (100*(c.99 heading 'Block Read Ratio' column bwratio format 999. c.phywrts). (100*(a.file#. rem title 'File IO Statistics Report' spool fileio&&today select a. (a.0) sum_io2 from sys.phyblkwrt/greatest(c.(c.999 heading 'Percent Of IO' column brratio format 999.v_$filestat a.1)) bwratio from sys. a.v_$tempfile d where c.phywrts).phywrts.phyblkrd/greatest(a.phyblkwrt.phyblkrd. set feedback off verify off lines 132 pages 60 sqlbl on trims on rem select nvl(sum(a.1)) brratio. select nvl(sum(b.phyrds+c. a.phyrds.'ddmonyyyyhh24miss') dt from dual.phyrds+a. sys.name.phyrds+a.phywrts.phyrds. (c.1)) brratio.1)) bwratio from sys.phyblkwrt. rem rem Mike Ault rem column sum_io1 new_value st1 noprint column sum_io2 new_value st2 noprint column sum_io new_value divide_by noprint column Percent format 999. c. c.phyblkrd. (a.

select sysdate into now from dual. sum_io1 number.sql rem rem FUNCTION: PL/SQL to calculate IO/sec data rem Mike Ault rem set serveroutput on declare cursor get_io is select nvl(sum(a.999. sum_io2. tot_io_per_sec:=tot_io/elapsed_seconds.999. sum_io22 number. select sum_io12+sum_io22 into tot_io from dual.'9.phywrts). fixed_io_per_sec number. Use at your own risk. if i = 1 then sum_io12:=sum_io1. .put_line('Temp IO/SEC :' to_char(temp_io_per_sec. for i in 1.. sum_io2 number.gv_$tempstat b. end loop. else sum_io22:=sum_io2.put_line('Fixed IO/SEC:' to_char(fixed_io_per_sec. end if.cc ************************************************* rem rem NAME: io_sec.to_number(null) sum_io2 from sys. elapsed_seconds number. dbms_output.phywrts). temp_io_per_sec:=sum_io22/elapsed_seconds.99')). To license this script for a commercial purpose.2 loop fetch get_io into sum_io1. select ceil((now-max(startup_time))*(60*60*24)) into elapsed_seconds from gv$ins tance.0) sum_io1. contact info@rampant.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. dbms_output. '9.clear columns ttitle off ---------io_sec.99')). '9.999. tot_io_per_sec number. begin open get_io. fixed_io_per_sec:=sum_io12/elapsed_seconds.phyrds+a.999.999. nvl(sum(b. temp_io_per_sec number.put_line('Elapsed Sec :' to_char(elapsed_seconds.phyrds+b. sum_io12 number.99')). now date.gv_$filestat a union select to_number(null) sum_io1. dbms_output. tot_io number.0) sum_io2 from sys.999.

99')).file#=d.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.d.999.cc ************************************************* rem rem NAME: snapfileio.999. / ---------- IO_TIMING.READTIM/PHYRDS. To license this script for a commercial purpose.99 heading 'Block Write Ratio' . end. Use at your own risk.999 heading 'Percent Of IO' column brratio format 999. '9.99 heading 'Block Read Ratio' column bwratio format 999.FILE# . rem Mike Ault rem column sum_io1 new_value st1 noprint column sum_io2 new_value st2 noprint column sum_io new_value divide_by noprint column Percent format 999.sql rem rem FUNCTION: Reports on the file io status of all of the rem datafiles in the database.file# order by readtim/phyrds desc / spool off ttitle off clear col ---------- Snapfileio.SQL rem rem Purpose: Calculate IO timing values for datafiles rem rem MIKE AULT rem col name format a30 set lines 132 pages 45 ttitle 'IO Timing Analysis' spool io_time select f.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.put_line('Total IO/SEC:' to_char(tot_io_Per_Sec.WRITETIM/PHYWRTS from v$filestat f.name.dbms_output.PHYRDS.PHYWRTS. Use at your own risk.cc ************************************************* rem IO_TIMING. To license this script for a commercial purpose. v$datafile d where f. contact info@rampant. contact info@rampant.

phyrds+b.phyblkwrt.phyrds. c.0) sum_io1 from stats$filestatxs a where snap_id=&&snap. c. c.phyblkrd/greatest(c.phywrts). (a.phywrts)/&divide_by) Percent.phywrts). select nvl(sum(b.phywrts.phywrts.1)) bwratio from stats$filestatxs a where a.phyrds. select &st1+&st2 sum_io from dual.1)) brratio.(c.phyrds+a.phyblkwrt. a.phywrts.phyblkwrt/greatest(a.phyrds.filename.snap_id=&&snap order by 1 / spool off pause Press enter to continue set feedback on verify on lines 80 pages 22 clear columns ttitle off undef snap ---------- physpctio.filename. (100*(c. a.column phyrds heading 'Physical Reads' column phywrts heading 'Physical Writes' column phyblkrd heading 'Physical Block Reads' column phyblkwrt heading 'Physical Block Writes' column filename format a45 heading 'File Name' column file# format 9999 heading 'File' set feedback off verify off lines 132 pages 60 sqlbl on trims on rem select nvl(sum(a.phyblkrd.phyblkrd.cc ************************************************* . a.1)) brratio.phyrds+a.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. rem ttitle132 'Snap&&snap File IO Statistics Report' spool fileio&&snap select a.0) sum_io2 from stats$tempstatxs b where snap_id=&&snap. c. To license this script for a commercial purpose. (100*(a.snap_id=&&snap union select c. a.phywrts)/&divide_by) Percent. contact info@rampant. (a.phyblkrd/greatest(a.phyrds. Use at your own risk.phyrds+c. (c.1)) bwratio from stats$tempstatxs c where c.phyblkwrt/greatest(c.phywrts.

v_$session b.v_$statname c.statistic#=c.p.name in ('physical reads'.username.2) tot_io_pct from (select b.select sid. nvl(b. (select sum(value) total_io €from sys.name) username. 'physical reads direct (lob)')) order by 3 desc. 'physical reads direct (lob)') group by b. nvl(b. 'physical writes direct (lob)'. 'physical writes direct'.statistic# and p.paddr (+) = b.v_$bgprocess p €where a. sum(value) total_user_io €from sys. sys. 'physical writes direct (lob)'.cc ************************************************* SID. 'physical writes'. ---------totpctio. username. To license this script for a commercial purpose.paddr and b.p.v_$statname c. USERNAME.2) TOT_IO_PCT FROM SELECT . ROUND(100 * TOTAL_USER_IO/TOTAL_IO.statistic# and c.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.sid. sys.name)).sid sid. sys. Use at your own risk. sys.statistic#=c.sid and c. round(100 * total_user_io/total_io. 'physical reads direct'. 'physical writes'.username.sid=a.name in ('physical reads'.v_$sesstat a €where a.v_$sesstat a. 'physical reads direct'. 'physical writes direct'. contact info@rampant.

paddr (+) = b. contact info@rampant. SUM(VALUE) TOTAL_USER_IO FROM sys.V_$SESSION b.STATISTIC#=c.null. Use at your own risk. 'physical reads direct'.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. 'consistent gets'.sid sid.'db block changes'. 'db block gets'. 'physical reads direct (lob)') GROUP BY b.b.V_$SESSTAT a WHERE a.username.USERNAME.username) user_name. sys. €€€'consistent changes'.'physical writes'.STATISTIC#=c.V_$STATNAME c. .SID=a.USERNAME. 'physical reads direct (lob)')) ORDER BY 3 DESC.V_$SESSTAT a.NAME in ('physical reads'.SID SID.NAME in ('physical reads'. 'consistent changes'. (select sum(value) TOTAL_IO from sys.name)). To license this script for a commercial purpose. 'physical writes direct (lob)'.SID.spid os_id. 'db block changes'.p. nvl(b. nvl(b.'consistent gets'. decode (b.name.v_$bgprocess p WHERE a. b.paddr and b.e.cc ************************************************* select b.STATISTIC# and c. sys. d. sys. 'physical writes direct'.p.STATISTIC# and p.V_$STATNAME c.SID and c.'physical writes'.(SELECT b.machine machine_name. 'physical reads direct'.NAME) USERNAME. € ---------- topiousers. 'physical writes direct'. €€€€€€'physical writes direct (lob)'.'db block gets'. sys.

v_$bgprocess e where a. value. 'db block gets'.to_char(logon_time.value.0)) rollbacks.value. sys.value.name.value.value.name.name.v_$sesstat a.0)) + sum(decode(c.name. 'db block changes'. 0))) / (sum (decode (c. value.'sorts (rows)'.name. (sum(decode(c.value.0)) + sum(decode(c.sid . sum(decode(c.value. 0))).'db block gets'.0)) + sum(decode(c.'mm/dd/yy hh:mi:ss pm') logon_time.name.0)) ) total_logical_io. 1)) + sum (decode (c.'execute count'.v_$statname c.value.name.0)) + sum(decode(c.0)) consistent_changes from €sys.value.name.statistic#=c.name.name.name. sum(decode(c. sys.value.0)) disk_sorts.v_$session b.name. 100 *(round ((sum (decode 100 (c.value.'consistent changes'.'user commits'.statistic# and b.0)) + sum(decode(c.value. sum(decode(c.'consistent gets'. 'physical reads direct'. 'consistent gets'. value.'physical reads'.0)) commits.'physical reads'.'sorts (memory)'. sys.name. sys.0)) db_block_gets. 'physical writes direct'. sum(decode(c.'sorts (disk)'.name.'physical writes'.v_$process d. sum(decode(c.value. sum(decode(c.name.name.value.'consistent changes'. (sum(decode(c.0)) rows_sorted.name.name.3)) hit_ratio.0)) + sum(decode(c.0))) total_physical_io.name. 'physical reads direct (lob)'.value. sum(decode(c.'db block gets'.value. 'physical writes direct (lob)'. sum(decode(c.name.value.value.0)) memory_sorts.0)) + sum(decode(c.value.sid=a.'consistent gets'. sum(decode(c.0)) + sum(decode(c.name.name.0)) executions.0)) consistent_gets. sum(decode(c. 'physical reads direct'.name. 'physical reads'. 0)) sum (decode (c.'user rollbacks'.value.name. value.0)) physical_reads.

a. count "value" from v$waitstat where class='data block' .999. 'execute count' ) group by b. 'user commits'. contact info@rampant.machine.sql rem Mike Ault rem col name format a46 heading 'DBWR Statistic' col stat format 9. 'consistent gets'. 'sorts (memory)'. 'db block changes'.and d. To license this script for a commercial purpose.name.addr = b.e. 'physical writes direct'.paddr and c.999 heading 'Statistic Value' set pages 40 ttitle 'DBWR Statistic Report' spool dbwr_stat select a. Use at your own risk.b.cc ************************************************* rem rem dbwr_stat.stat from (select name. 'sorts (rows)'. ---------- DBWR_STAT. 'sorts (disk)'. 'db block gets'.name. value stat from v$sysstat where name not like '%redo%' and name not like '%remote%') a where (a.paddr and e.paddr (+) = b. 'user rollbacks'.name like 'DBWR%' or a.username. 'physical writes'.name like '%buffer%' or a.spid. 'consistent changes'.'mm/dd/yy hh:mi:ss pm') order by 6 desc.999. d.username). b. decode (b.sid. 'physical writes direct (lob)'.name in ('physical reads'.name like '%write%' or name like '%summed%') union select class name.999. to_char(logon_time. 'physical reads direct'.null.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. 'physical reads direct (lob)'.

dba_data_files b where a.************************************************* -. physical_block_writes select from sys. round(((1 .3 -10g_filehistogram.file_id order by 1. file_name.union select name ' ' to_char(block_size/1024) ' hit ratio' name. average_write_time. Use at your own risk.free_buffer _wait stat from V$buffer_pool_statistics union select name ' ' to_char(block_size/1024) ' buffer busy wait' name. physical_reads.This script is free for non-commercial purposes .buffer_busy _wait stat from V$buffer_pool_statistics union select name ' ' to_char(block_size/1024) ' write complete wait' name.3) s tat from V$buffer_pool_statistics union select name ' ' to_char(block_size/1024) ' free buffer wait' name. physical_writes.file_id = b. average_read_time.(physical_reads / (db_block_gets + consistent_gets))) * 100). contact info@rampant. a. end_time.v_$filemetric_history a. physical_block_reads. sys.sql -.write_co mplete_wait stat from V$buffer_pool_statistics / spool off set pages 22 ttitle off ---------- 10g_filehist.Copyright © 2005 by Rampant TechPress -.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.file_id.cc ************************************************* begin_time. To license this script for a commercial purpose.

null.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.' n. sys. Use at your own risk. logical_reads_total "Logical Reads" .logical_rea ds_total.' n.logical_reads_total. e.nvl(b. tablespace_name "Tablespace Name" . n.object_type .subobject_name else substr(n.nvl(b. To license this script for a commercial purpose. e.file# = b. file_name.dataobj# . object_type "Object Type" . r. singleblkrdtim_milli.------ with no warranties.subobject_name)-9) end subobject_name . e. n.length(n. v_$file_histogram a.subobject_name) < 11 then n.file_id.subobject_name.subobject_name.logical_reads_total . ratio "%Total" from( select n.sub object_name) object_name . Use at your own risk. 0)) over () ratio €€€€€from dba_hist_seg_stat e .logical_reads_total .file_id order by 1 ---------- seg_top_logreads_10g.object_name decode(n. To license this script for a commercial purpose. (select * from (select e.null. singleblkrds select from sys.'.cc ************************************************* select object_name "Object Name" . case when length(n. contact info@rampant. contact info@rampant.dba_data_files b where a. 2) ratio from dba_hist_seg_stat_obj n . round(r.logical_reads_total . 0) log ical_reads_total .obj# .owner '.dbid .ratio * 100. ratio_to_report(e.cc ************************************************* b.tablespace_name .

phyrds .dataobj# = r. from .nvl(b.dbid = &pDbId b. €where and and and and and and and and and €group union select e.instance_number b.nvl(b. dba_hist_seg_stat b where b.nvl(b.dataobj# and n.file# ( (e.logical_reads_total.phywrts . From ( select .phywrts .dbid(+) = e.dbid = r.file# €= e.instance_number = 1 and e.obj# €€€= b.phywrts .dbid(+) = &pDbId e.tsname tbsp .dbid = 37933856 and b.snap_id(+) = &pBgnSnap .dataobj# = b.dbid €= 37933856 and e.instance_number(+) = &pInstNum e.nvl(b.instance_number(+) = e.0) ) + (e.snap_id(+) = &pBgnSnap e.phyrds .phyrds.0)) + sum (e.phywrts.0)) ) > 0 by e.logical_reads_total .nvl(b. To license this script for a commercial purpose.obj# and e.obj# and n.dbid b.0)) + sum (e.phyrds.tsname tbsp sum (e. contact info@rampant.phywrts.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.obj# = r.nvl(b.dataobj# and e. Use at your own risk.cc ************************************************* tbsp Tablespace ios "I/O Activity" e.snap_id = &pEndSnap b. dba_hist_tempstatxs b €where b.instance_number = 1 and e.instance_number = &pInstNum b. 0) > 0 order by logical_reads_total desc) d where rownum <= 100) r €where n.tsname select . sum (e..phywrts.0)) ios dba_hist_filestatxs e dba_hist_filestatxs b b.snap_id = 2707 and b.0)) ios from dba_hist_tempstatxs e .phyrds .dbid ) order by logical_reads_total desc € ---------- db_tbsp_io_10g.nvl(b.snap_id = 2694 and e.phyrds.

dba_data_files df.instance_number = &pInstNum b.nvl(b.instance_number b.snap_id = snap.instance_number(+) = &pInstNum e.snap_id = &pEndSnap b.file_name. dba_objects obj where wait. time from dba_hist_waitstat wait.instance_number(+) = e.dbid = &pDbId b.0) ) ) > 0 €group by e.phyrds.phywrts .snap_id .snap_id and wait.0) ) + (e. -.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. dba_hist_snapshot snap.dbid(+) = &pDbId e.snap_id = ash. prompt set pages 999 set lines 80 break on snap_time skip 2 col col col col col col snap_time file_name object_type object_name wait_count time heading heading heading heading heading heading 'Snap Time' 'File Name' 'Object Type' 'Object Name' 'Wait Count' 'Time' format format format format format format a20 a40 a10 a20 999.dbid(+) = e.999 999.cc ************************************************* prompt prompt This will compare values from dba_hist_waitstat with prompt detail information from dba_hist_active_sess_history.phyrds .dbid b. contact info@rampant. object_name.nvl(b.'yyyy-mm-dd hh24:mi') snap_time.phywrts. Use at your own risk.999 select to_char(begin_interval_time.e. object_type.tsname ) and and and and and and and and and ---------- wait_time_detail_10g.file# = e. dba_hist_active_sess_history ash. To license this script for a commercial purpose. wait_count.file# ( (e.

file_name . Use at your own risk. Use at your own risk. contact info@rampant.and df.current_file# and obj.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.cc ************************************************* break on begin_interval_time skip 2 column phyrds format 999. prompt set pages 999 . To license this script for a commercial purpose. ---------- phys_disk_reads_10g.999 column begin_interval_time format a25 select begin_interval_time. phyrds from dba_hist_filestatxs natural join dba_hist_snapshot .999. ---------- rpt_10g_sysstat.file_id = ash.object_id = ash. filename.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. contact info@rampant.cc ************************************************* prompt prompt This will query the dba_hist_sysstat view to display all values prompt that exceed the value specified in prompt the "where" clause of the query.'yyyy-mm-dd hh24:mi').current_obj# and wait_count > 50 order by to_char(begin_interval_time. To license this script for a commercial purpose.

cc ************************************************* prompt prompt This will identify any single file who's write I/O prompt is more than 25% of the total write I/O of the database.999 format a20 select to_char(begin_interval_time.999 select to_char(begin_interval_time. prompt set pages 999 break on snap_time skip 2 col filename col phywrts col snap_time format a40 format 999.break on snap_time skip 2 accept stat_name char prompt 'Enter Statistic Name: '. accept stat_value number prompt 'Enter Statistics Threshold value: '. filename. phywrts from dba_hist_filestatxs natural join dba_hist_snapshot where phywrts > 0 . ---------- hot_write_files_10g.'yyyy-mm-dd hh24:mi') . value from dba_hist_sysstat natural join dba_hist_snapshot where stat_name = '&stat_name' and value > &stat_value order by to_char(begin_interval_time.999. Use at your own risk. col snap_time col value format a19 format 999.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.999.'yyyy-mm-dd hh24:mi') snap_time. To license this script for a commercial purpose. contact info@rampant.'yyyy-mm-dd hh24:mi') snap_time.

and phywrts * 4 > ( select avg(value) all_phys_writes from dba_hist_sysstat natural join dba_hist_snapshot where stat_name = 'physical writes' and value > 0 ) order by to_char(begin_interval_time.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.'hh24') order by . contact info@rampant. To license this script for a commercial purpose. col snap_time col avg_value format a19 format 999. phywrts desc .cc ************************************************* prompt prompt prompt This will query the dba_hist_sysstat view to prompt display average values by hour of the day prompt set pages 999 break on snap_time skip 2 accept stat_name char prompt 'Enter Statistics Name: '. avg(value) avg_value from dba_hist_sysstat natural join dba_hist_snapshot where stat_name = '&stat_name' group by to_char(begin_interval_time.'yyyy-mm-dd hh24:mi').999.999 select to_char(begin_interval_time.'hh24') snap_time. Use at your own risk. ---------- rpt_sysstat_hr_10g.

'day') order by decode( to_char(begin_interval_time.sql -.cc ************************************************* prompt prompt This will query the dba_hist_sysstat view to display prompt average values by day-of-the-week prompt set pages 999 accept stat_name char prompt 'Enter Statistic Name: '. ---------- rpt_sysstat_dy_10g. Use at your own risk. To license this script for a commercial purpose.2.************************************************* -.999 select to_char(begin_interval_time.999. avg(value) avg_value from dba_hist_sysstat natural join dba_hist_snapshot where stat_name = '&stat_name' group by to_char(begin_interval_time. 'monday'.'day').4.1.Copyright © 2005 by Rampant TechPress -.5. col snap_time col avg_value format a19 format 999.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.'hh24') .7 ) . 'thursday'.'day') snap_time. 'saturday'.This script is free for non-commercial purposes . 'tuesday'.to_char(begin_interval_time. -reads_10g. 'sunday'. 'wednesday'.6.3. contact info@rampant. 'friday'.

To license this script for a commercial purpose. --. -snapfileio_10g.999 column begin_interval_time format a25 select begin_interval_time. Use at your own risk. phyrds from dba_hist_filestatxs natural join dba_hist_snapshot.contact info@rampant.999. column column column column column column column column column column column column sum_io1 new_value st1 noprint sum_io2 new_value st2 noprint sum_io new_value divide_by noprint Percent format 999.99 heading 'Block Write Ratio' phyrds heading 'Physical Reads' phywrts heading 'Physical Writes' phyblkrd heading 'Physical Block Reads' phyblkwrt heading 'Physical Block Writes' filename format a45 heading 'File Name' file# format 9999 heading 'File' set feedback off verify off lines 132 pages 60 sqlbl on trims on select nvl(sum(a.cc ************************************************* break on begin_interval_time skip 2 column phyrds format 999.************************************************* -. filename.phyrds+a.To license this script for a commercial purpose. -.0) sum_io1 from dba_hist_filestatxs a where snap_id=&&snap.------ with no warranties.Copyright © 2005 by Rampant TechPress -.with no warranties.sql rem FUNCTION: Reports on the file io status of all of the rem FUNCTION: datafiles in the database for a single snapshot. Use at your own risk.************************************************* rem rem NAME: snapfileio.99 heading 'Block Read Ratio' bwratio format 999.This script is free for non-commercial purposes -.999 heading 'Percent Of IO' brratio format 999. contact info@rampant.cc -. .phywrts).sql -.

phyrds.phyblkwrt/greatest(c.0) sum_io2 from dba_hist_tempstatxs b where snap_id=&&snap.To license this script for a commercial purpose.phyrds.phyblkwrt/greatest(a.phyblkwrt.contact info@rampant. rem HISTORY: . select &st1+&st2 sum_io from dual.with no warranties. c.phyblkrd/greatest(a.phywrts.phyrds+a. (a. a.1)) brratio. a.phywrts.snap_id=&&snap union select c.(c. (c.select nvl(sum(b. Use at your own risk. (100*(a. rem @title132 'Snap&&snap File I/O Statistics Report' spool rep_out\&db\fileio&&snap select a.phywrts)/&divide_by) Percent.phyrds+c.sql -. (100*(c.cc -.phyblkwrt.1)) bwratio from dba_hist_filestatxs a where a.phywrts)/&divide_by) Percent.Copyright © 2005 by Rampant TechPress -.snap_id=&&snap order by 1 / spool off pause Press enter to continue set feedback on verify on lines 80 pages 22 clear columns ttitle off undef snap -snapdeltafileio_awr. -. (a.phyrds+b.1)) bwratio from dba_hist_tempstatxs c where c. c. c.1)) brratio. c.phyrds.filename.This script is free for non-commercial purposes -.filename.phyblkrd/greatest(c.************************************************* -.sql rem rem FUNCTION: Reports on the file io status of all of rem FUNCTION: the datafiles in the database across rem FUNCTION: two snapshots.phywrts. a. --.phyrds.************************************************* rem rem NAME: snapdeltafileio_awr.phywrts.phyblkrd.phyblkrd. a.phywrts).

phywrts-a. select &st1+&st2 sum_io from dual.phyblkwrt phyblgwrt.phywrts).0) sum_io2 from dba_hist_tempstatxs a.999 heading 'Percent Of IO' column brratio format 999.filename union select c.snap_id=&&first_snap_id and b.phywrts-a.1)) bwratio from dba_hist_tempstatxs c.phyblkrd. ((b.phyrds)+(d.phyrds)+(b. d.phyblkwrt-a.filename.phyblkwrt phyblgwrt.filename.phyblkrd)/greatest((d.phyrds-a.phyblkrd phyblkrd.phywrts-a. d.phyblkwrt-a.snap_id=&&sec_snap_id and a.phyblkrd)/greatest((b.phyblkrd-c.phyrds phyrds.phyrds -a. b.phywrts)).99 heading 'Block Read Ratio' column bwratio format 999.phyblkwrt)/greatest((b.snap_id=&&sec_snap_id and a.phyrds).phyrds)+(b. b.phyrds-c.phywrts).rem WHO rem Mike Ault rem WHAT Created WHEN 11/19/03 column sum_io1 new_value st1 noprint column sum_io2 new_value st2 noprint column sum_io new_value divide_by noprint column Percent format 999.phyblkrd-c.phywrts))/&divide_by) Percent.snap_id=&&first_snap_id and b.filename.phyblkwrt-c. ((d.filename=b. dba_hist_tempstatxs b where a.phyblkwrt-c. ((d.0) sum_io1 from dba_hist_filestatxs a.phyblkwrt)/greatest((d.snap_id=&&first_snap_id and b. b.phyrds-a. rem @title132 'Snap &&first_snap_id to &&sec_snap_id File I/O Statistics Report' spool rep_out\&db\fileio'&&first_snap_id'_to_'&&sec_snap_id' select a.filename=b.phyrds-c.filename=b.1)) brratio.phyblkrd phyblkrd.phyrds-a.phywrts))/&divide_by) Percent. d. dba_hist_filestatxs b where a.phyrds-a. d. (100*((b.phyrds).phywrts phywrts. ((b.phywrts-c. (100*((d. b.a.phywrts-a.phywrts phywrts.phyrds phyrds.phyblkrd-a.phywrts-c.phyrds)+(b.snap_id=&&sec_snap_id and a. dba_hist_tempstatxs d .phywrts-a.phywrts)). select nvl(sum((b.99 heading 'Block Write Ratio' column phyrds heading 'Physical Reads' column phywrts heading 'Physical Writes' column phyblkrd heading 'Physical Block Reads' column phyblkwrt heading 'Physical Block Writes' column filename format a45 heading 'File Name' column file# format 9999 heading 'File' set feedback off verify off lines 132 pages 60 sqlbl on trims on select nvl(sum((b.1)) brratio. dba_hist_filestatxs b where a.phywrts-c.phyrds-c.1)) bwratio from dba_hist_filestatxs a.filename.

Use at your own risk.snap_id=&&sec_snap_id and c. Use at your own risk. To license this script for a commercial purpose.filename order by 1 / spool off pause Press enter to continue set feedback on verify on lines 80 pages 22 clear columns ttitle off undef first_snap_id undef sec_snap_id ---------- awr_physrds.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. select . contact info@rampant.999.filename=d.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.snap_id=&&first_snap_id and d. To license this script for a commercial purpose. ---------- latchdet. contact info@rampant.999 column begin_interval_time format a25 column file_name format a45 select begin_interval_time.cc ************************************************* break on begin_interval_time skip 1 column phyrds €€€€€format 999.cc ************************************************* name.where c. filename. phyrds from dba_hist_filestatxs natural join dba_hist_snapshot order by begin_interval_time .

gets.999 heading 'Gets' col misses format 9.0.2) imisses.1.999.999. Use at your own risk.cc ************************************************* REM REM Script to determine sleeps for latches REM M.2) spins.0. R.999.999 heading 'Sleeps' set pages 55 ttitle80 'Latches Contention Report' spool latches_con select name.0. immediate_gets igets.sleeps from v$latch where gets>0 and misses>0 order by g ets desc / spool off clear columns ttitle off ---------- waiters.999 heading 'Misses' col sleeps format 999.v_$latch order by 2 desc.gets. round(misses*100/decode(gets. sleeps from sys.999. round(immediate_misses*100/ decode(immediate_gets.cc ************************************************* busername wusername bsession_id wsession_id FORMAT a10 FORMAT a10 HEADING HEADING HEADING HEADING 'Holding 'Waiting 'Holding 'Waiting User' User' SID' SID' COLUMN COLUMN COLUMN COLUMN .misses). contact info@rampant.999. To license this script for a commercial purpose. contact info@rampant. ---------- Latch_sleep.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. Use at your own risk.misses. Ault 2005 REM col name format a30 heading 'Latch Name' col gets format 99.1. round(spin_gets*100/decode(misses.immediate_gets). To license this script for a commercial purpose.2) misses.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.gets).1.

waiting_session=a.v_$session b. mode_requested.sid and c. To license this script for a commercial purpose.sid .sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. contact info@rampant. lock_id1. SPOOL OFF PAUSE press Enter to continue CLEAR COLUMNS SET LINES 80 PAGES 22 FEEDBACK ON TTITLE OFF ---------- blockers. lock_id2 FROM sys. Use at your own risk. c.cc ************************************************* username session_id mode_held mode_requested lock_id1 lock_id2 type FORMAT a10 FORMAT FORMAT FORMAT FORMAT a10 a10 a10 a10 HEADING HEADING HEADING HEADING HEADING HEADING HEADING 'Holding User' 'SID' 'Mode Held' 'Mode Requested' 'Lock ID1' 'Lock ID2' 'Lock Type' COLUMN COLUMN COLUMN COLUMN COLUMN COLUMN COLUMN SET LINES 132 PAGES 59 FEEDBACK OFF ECHO OFF ttitle 'Sessions Blocking Other Sessions Report' SPOOL blockers . waiting_session wsession_id. sys. b.dba_waiters c.COLUMN COLUMN COLUMN COLUMN COLUMN mode_held mode_requested lock_id1 lock_id2 type FORMAT FORMAT FORMAT FORMAT a10 999999 999999 a15 HEADING HEADING HEADING HEADING HEADING 'Mode 'Mode 'Lock 'Lock 'Lock Held' Requested' ID1' ID2' Type' SET LINES 132 PAGES 59 FEEDBACK OFF ECHO OFF ttitle 'Processes Waiting on Locks Report' SPOOL waiters SELECT holding_session bsession_id. mode_held.v_$session a WHERE c.username busername.lock_type type. sys.holding_session=b.username wusername. a.

dba_blockers c. SPOOL OFF PAUSE press Enter to continue CLEAR COLUMNS SET LINES 80 PAGES 22 FEEDBACK ON ---------- ddl_lock. mode_requested.dba_lock a WHERE c.cc ************************************************* owner session_id mode_held mode_requested type name FORMAT FORMAT FORMAT FORMAT FORMAT FORMAT a7 9999 a7 a7 a20 a21 HEADING 'User' HEADING 'SID XE "SID" ' HEADING 'Lock Mode Held' HEADING 'Lock Mode Request' HEADING 'Type Object' HEADING 'Object Name' COLUMN COLUMN COLUMN COLUMN COLUMN COLUMN SET FEEDBACK OFF ECHO OFF PAGES 48 LINES 79 ttitle 'Report on All DDL Locks Held' SPOOL ddl_lock SELECT NVL(owner.3 . lock_id2 FROM sys. lock_id1. SPOOL OFF PAUSE press Enter/return to continue .sid . mode_held.holding_session=b. sys. name. mode_requested FROM sys. Use at your own risk. contact info@rampant. type.v_$session b.holding_session=a.'SYS') owner. To license this script for a commercial purpose. type. sys.2. session_id.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. username.session_id AND c. mode_held.session_id.dba_ddl_locks ORDER BY 1.SELECT a.

Use at your own risk. To license this script for a commercial purpose. session_id.cc ************************************************* username session_id lock_type mode_held FORMAT a10 FORMAT a27 FORMAT a10 HEADING HEADING HEADING HEADING 'Lock 'User 'Lock 'Mode Holder' SID' Type' Held' COLUMN COLUMN COLUMN COLUMN . name. contact info@rampant.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.'SYS') owner. mode_requested FROM sys.dba_dml_locks ORDER BY 2 . To license this script for a commercial purpose.CLEAR COLUMNS SET FEEDBACK ON PAGES 22 LINES 80 TTITLE OFF ---------- dml_lock. mode_held. contact info@rampant. Use at your own risk.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.cc ************************************************* owner session_id mode_held mode_requested FORMAT a8 FORMAT a10 FORMAT a10 HEADING 'User' HEADING 'SID XE "SID" ' HEADING 'Mode Held' HEADING 'Mode Requested' COLUMN COLUMN COLUMN COLUMN SET FEEDBACK OFF ECHO OFF PAGES 59 LINES 80 ttitle 'Report on All DML Locks Held' SPOOL dml_lock SELECT NVL(owner. SPOOL OFF PAUSE press Enter to continue CLEAR COLUMNS SET FEEDBACK ON PAGES 22 LINES 80 TTITLE OFF ---------- int_lock.

dba_lock_internal a. To license this script for a commercial purpose. Use at your own risk.'SYS') username. contact info@rampant.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.lock_id2 FROM sys.username.v_$session b WHERE UPPER(mode_held) like UPPER('%&mode%') OR UPPER('&mode')='ALL' AND UPPER(lock_type) like UPPER('%&lock%') OR UPPER(mode_held) like UPPER('%&mode%') OR UPPER('&mode')='ALL' AND UPPER('&lock')='ALL' AND a.sid ORDER BY 1.cc ************************************************* REM REM Waits per Datafile report REM M.lock_id1. sys. session_id.session_id=b.2 . SPOOL OFF PAUSE press Enter to continue SET LINES 80 PAGES 22 FEEDBACK ON VERIFY ON CLEAR COLUMNS CLEAR BREAKS UNDEF LOCK UNDEF MODE ---------- Waits_file.lock_type.COLUMN mode_requested FORMAT a10 COLUMN lock_id1 FORMAT a30 COLUMN lock_id2 FORMAT a10 HEADING 'Mode Requested' HEADING 'Lock/Cursor ID1' HEADING 'Lock ID2' PROMPT 'ALL is all types or modes' ACCEPT lock PROMPT 'Enter Desired Lock Type: ' ACCEPT mode PROMPT 'Enter Lock Mode: ' SET LINES 132 PAGES 59 FEEDBACK OFF ECHO OFF VERIFY OFF BREAK ON username ttitle 'Report on Internal Locks Mode: &mode Type: &lock' SPOOL int_locks SELECT NVL(b. mode_requested. Ault 2005 REM .mode_held.

time wait_time.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. name. time/count ratio FROM x$kcbfwait.999. name. v$datafile WHERE indx + 1 = file# AND time>0 Order By count DESC / spool off clear columns clear computes ttitle off set pages 22 lines 80 ---------- Waits_file.999 wait_time heading 'Time' ratio heading 'Time Count' format 999.cc ************************************************* col name format a50 heading 'Data File Name' col count format 999.99 set pages 47 compute sum of count on report break on report ttitle 'Waits Per Datafile' set lines 132 spool waits_file SELECT file#.999 col wait_time heading 'Time' col ratio heading 'Time Count' format 999. To license this script for a commercial purpose. Use at your own risk. count.999 heading 'Wait Count' col file# heading 'File#' format 9.col col col col col name format a66 heading 'Data File Name' count format 999. contact info@rampant. time wait_time.999. time/count ratio FROM x$kcbfwait.99 set pages 47 compute sum of count on report break on report ttitle 'Waits Per Datafile' set lines 132 spool waits_file SELECT file#. v$datafile WHERE indx + 1 = file# AND time>0 Order By count DESC / spool off clear columns .999 heading 'Wait Count' file# heading 'File#' format 9. count.

Use at your own risk.clear computes ttitle off set pages 22 lines 80 ---------- 10g_sysclasssum. round((time_waited / 100). contact info@rampant. contact info@rampant. Use at your own risk.2) pct_waits. . round(100 * (total_waits / sum_waits).end_time. total_waits. to_char(a.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. sum(time_waited) sum_time from v$system_wait_class where wait_class != 'Idle') order by 5 desc ---------- €10g_sysclasshist. To license this script for a commercial purpose.99 HEADING 'Time Waited' select b.2) time_waited_secs. To license this script for a commercial purpose.cc ************************************************* wait_class.wait_class.999. round(100 * (time_waited / sum_time). time_waited from v$system_wait_class where wait_class != 'Idle').2) pct_time select from (select wait_class. (select sum(total_waits) sum_waits.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.cc ************************************************* col Time format a20 HEADING 'Time' col wait_class format a20 HEADING 'Wait Class' col time_waited format 999. total_waits.999.'YYYY-MON-DD HH') Time.

end_time.time_waited_micro .nvl(b1. Use at your own risk.0)) from dba_hist_system_event b1 . e.wait_class != 'Idle' group by wait_class.time_waited / 100).sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.nvl(b.'YYYY-MON-DD HH') order by 1. time "Wait Time (s)" . pct*100 "Percent of Total" . contact info@rampant.snap_id = e.cc ************************************************* select event .2 ---------- 10g_waithist. (e.sum(round((a.snap_id .4) wait_time_secs.2)) time_waited from sys.v_$event_histogram where event = 'db file scattered read' order by 2 ---------- wt_events_int_10g.snap_id and e1. contact info@rampant.time_waited_micro. (e. To license this script for a commercial purpose.time_waited_micro .0))/ (select sum(e1.snap_id(+) = b.nvl(b. Use at your own risk.0))/100000 0 time .total_waits . To license this script for a commercial purpose. dba_hist_system_event e1 where b1.time_waited_micro .v_$waitclassmetric_history a. to_char(a.wait_class# and b. sys. waitclass "Wait Class" from (select e.time_waited_mic ro.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. wait_count select from sys.event_name event .cc ************************************************* round((wait_time_milli / 1000).0) waits .wait_class# = b.nvl(b.v_$system_wait_class b where a.time_waited_micro.total_waits. waits "Waits" .

sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.total_waits. to_number(NULL) .snap_id(+) = &pBgnSnap .instance_number = e.wait_class <> 'Idle' order by time desc.0))/1000) / (e.total_waits.total_waits e1.total_waits. waitclass "Wait Class" from €(select e.snap_id = &pEndSnap and b.time_waited_micro .total_timeouts .event_id > nvl(b1.wait_class waitclass from dba_hist_system_event b . 0. dba_hist_system_event e where b.total_timeouts. (e.cc ************************************************* select event "Event Name".wait_class = b.event_id and e.instance_number(+) e1. 0)).0) and e.0))/1000000 time .time_waited_micro.instance_number b1.0) <> 'Idle' .nvl(b.time_waited_micro.event_name event .event_id(+) = e. contact info@rampant.nvl(b.instance_number(+) = &pInstNum €€€and e.time_waited_micro .total_waits. e.and and and and and and and ) pct b1.nvl(b.nvl(b.instance_number = &pInstNum and b. Use at your own risk. €€€dba_hist_system_event e where b.event_id(+) e1.dbid(+) e1.0)) ) avgwait .nvl(b.dbid(+) = &pDbId and e. To license this script for a commercial purpose. decode ((e.0) timeouts .total_waits.wait_class waitclass from dba_hist_system_event b . e. avgwait "Avg Wait (ms)".dbid = e. e.dbid = b. time "Wait Time (s)".instance_number = e1. waits "Waits".dbid = &pDbId €€€and b. ((e. e. waits desc ) ---------- sys_event_int_10g.nvl(b. timeouts "Timeouts".total_waits .snap_id(+) = &pBgnSnap and e.total _waits .total_waits .0) waits .total_waits > nvl(b.dbid b1.

instance_number = e.nvl(b. contact info@rampant. €where and and and and and and and and and €order ---------- ash_waitclass_waits.instance_number(+) and e.total_waits and e.nvl(b.instance_number = &pInstNum e.instance_number b.snap_id = &pBgnSnap e.wait_count . .instance_number and b.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.cc ************************************************* e.time . Use at your own risk.wait_count.snap_id and b.wait_count.class b.dbid(+) and e.dbid b. To license this script for a commercial purpose.dbid and b.CLASS" e.0) "Waits" e.instance_number = &pInstNum b.class = e.event_id(+) and e.dbid = &pDbId b.wait_count by 3 desc.cc ************************************************* break on begin_time skip 1 column wait_class format a15 .dbid = &pDbId e.0)) / (e.snap_id = &pEndSnap b.0) "Total Wait Time (cs)" (e. Use at your own risk.event_id > nvl(b.dbid = e.total_waits.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. contact info@rampant.wait_count . waits desc = &pEndSnap = &pDbId = &pDbId = &pInstNum = &pInstNum = e.0)) "Avg Time (cs)" dba_hist_waitstat b dba_hist_waitstat e b.wait_class order by time desc. .and e.class "E.time €€€€€.nvl(b.time. To license this script for a commercial purpose.0) <> 'Idle' ) ---------- wait_stat_int_10g.wait_count < e.nvl(b. from . 2 desc select .time.

b.gets .b. to_number(decode(e.sleeps . null.wait_time .instance_number = &pInstNum and e. (e.misses .immediate_misses) * 100 / (e. To license this script for a commercial purpose.immediate_gets . e.b.b.misses) * 100/(e.snap_id €€€€€€€€= &pBgnSnap and e.instance_number and b. b.misses .gets. average_waiter_count DESC. b.select begin_time.latch_hash and e.immediate_gets.immediate_gets "No Wait Requests" . wait_class. e. contact info@rampant.dbid = e.cc ************************************************* select e.b. Use at your own risk.gets > 0 €order by 1. to_number(decode(e. null.dbid = &pDbId and b.b.gets "Get Requests" .b. to_number(decode(e.************************************************* -.immediate_misses .immediate_gets))) "Percent No Wa it Miss" €from dba_hist_latch b . dbtime_in_wait from dba_hist_waitclassmet_history where dbtime_in_wait >10 order by begin_time.b.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.misses. (e. 4 -latch_miss_int_10g. (e.sleeps)/(e. average_waiter_count.b.immediate_gets.gets .latch_name "Latch Name" .gets))) "Percent Get Misses" .dbid and b.latch_hash = e. ---------- latch_int_10g.dbid = &pDbId and e.instance_number = e. dba_hist_latch e €where b.misses.b.misses))) "Avg Sleeps / Miss" .sql -. b.Copyright © 2005 by Rampant TechPress .snap_id = &pEndSnap and b.instance_number = &pInstNum and b. null.gets. (e.immediate_gets . wait_class.gets .wait_time)/1000000 "Wait Time (s)" .

prompt set pages 999 set lines 80 break on snap_time skip 2 col col col col snap_time file_name object_type object_name heading heading heading heading 'Snap Time' 'File Name' 'Object Type' 'Object Name' format format format format a20 a40 a10 a20 .dbid(+) = e.where_in_code e. sleeps "Sleeps".------- This script is free for non-commercial purposes with no warranties.nwfail_count . contact info@rampant.nvl(b.sleep_count . To license this script for a commercial purpose.cc ************************************************* prompt prompt This will compare values from dba_hist_waitstat with prompt detail information from dba_hist_active_sess_history.sleep_count > nvl(b. Use at your own risk. contact info@rampant.wtr_slp_count .0) waiter_sleeps dba_hist_latch_misses_summary b dba_hist_latch_misses_summary e b.cc ************************************************* latchname "Latch Name".nwfail_count. €where and and and and and and and and and and ) €order ---------- wait_time_detail_10g.wtr_slp_count.where_in_code latchname e.sleep_count. To license this script for a commercial purpose.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.instance_number = &pInstNum b. Use at your own risk.instance_number(+) = e.parent_name(+) = e.dbid b. . from .parent_name ' ' e.0) sleeps e. .dbid(+) = &pDbId e.snap_id(+) = &pBgnSnap e.nvl(b. 3 desc select From ( select .0) nwmisses e.dbid = &pDbId b.instance_number b.snap_id = &pEndSnap b.sleep_count.instance_number(+) = &pInstNum e.where_in_code(+) = e.parent_name b.0) by 1. nwmisses "No Wait Misses".nvl(b. €waiter_sleeps "Waiter Sleeps" e.

---------- resource_waits. wait_count.snap_id = ash.cc ************************************************* select ash.sql . dba_objects obj where wait.999 select to_char(begin_interval_time.event. To license this script for a commercial purpose.col wait_count col time heading 'Wait Count' format 999. dba_hist_active_sess_history ash. time from dba_hist_waitstat wait.sample_time between sysdate . Use at your own risk.snap_id = snap.current_obj# and wait_count > 50 order by to_char(begin_interval_time. dba_data_files df.999 heading 'Time' format 999.snap_id and wait. -- user_waiting. dba_hist_snapshot snap.wait_time + ash. object_type.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. file_name .file_id = ash. -.event order by 2.60/2880 and sysdate group by ash.'yyyy-mm-dd hh24:mi').snap_id and df. object_name.object_id = ash.current_file# and obj.'yyyy-mm-dd hh24:mi') snap_time.file_name. contact info@rampant. sum(ash.time_waited) ttl_wait_time from v$active_session_history ash where ash.

To license this script for a commercial purpose. -------- ash_event_rollup. Use at your own risk.cc ************************************************* select sess.sid.wait_time + ash.************************************************* -.************************************************* break on wait_class skip 1 column event_name format a40 column wait_class format a20 select wait_class.Copyright © 2005 by Rampant TechPress -.sid.contact info@rampant. -.session_id = sess.with no warranties.cc -. To license this script for a commercial purpose.--------- ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. . sum(ash. sess. --.sample_time > sysdate-1 and ash. < ash_list_events. Use at your own risk. sess. contact info@rampant.To license this script for a commercial purpose.sql -.time_waited) wait_time from v$active_session_history ash.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.username order by 3.username. event_name from dba_hist_event_name order by wait_class.sid group by sess.This script is free for non-commercial purposes -. Use at your own risk. v$session sess where ash. event_name.

sid.999.cc ************************************************* select swh.'yyyy-mm-dd HH24').event) €€€€€€€€€€€€€€€€total_waits. e. swh. 999.999.sample_time.seq#.'yyyy-mm-dd') skip 1. count(e.-.event event.'yyyy-mm-dd HH24') mydate. Use at your own risk.cc -.username username. sum(e. contact info@rampant.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.sample_time. ---------- ash_event_hist. e. break on to_char(snap_time. swh.event not like '%message%' and e.p2 from v$session sess. 999. sess.event) > 100 group by to_char(e.event order by 1 . To license this script for a commercial purpose.event.p1. 9.999. v$session_wait_history swh where . swh. Mo Dy Hr' format format heading 'tot waits' format heading 'time wait' format heading 'timeouts' format a13. a30.************************************************* ttitle 'High waits on events Rollup by hour' column column column column column mydate heading event total_waits time_waited total_timeouts 'Yr.contact info@rampant.time_waited) time_waited from v$active_session_history e where e. €select to_char(e.event not like '%slave wait%' having count(e. sess.event not like '%timer' and e.

cc ************************************************* select h. ---------- €ash_sql.seq#.session_id = 74 AND h. To license this script for a commercial purpose.sql_id = s.sql_id. contact info@rampant. Use at your own risk.sql_id and s.sess.sql_id = s. ---------- ash_event_count.sid order by swh.sql_fulltext like %orders% .sql_id.sql_text from dba_hist_active_sess_history h. count(*) from dba_hist_active_sess_history h. Use at your own risk. To license this script for a commercial purpose.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.sid = swh. v$sql s where h.sid = 74 and sess.sql_fulltext like %orders% having .sample_time) = TRUNC(SYSDATE) AND s. v$sql s where h.sql_id AND TRUNC(h. contact info@rampant. s.cc ************************************************* select h.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.

999 select to_char(begin_interval_time.'yyyy-mm-dd hh24:mi').object_id = ash. dba_hist_active_sess_history ash. dba_data_files df.snap_id = ash.snap_id and df. wait_count. -.current_file# and obj. dba_objects obj where wait.sql_id order by 2 DESC. file_name .snap_id = snap. Use at your own risk.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.current_obj# and wait_count > 50 order by to_char(begin_interval_time. . ---------- wait_time_detail. dba_hist_snapshot snap. time from dba_hist_waitstat wait.'yyyy-mm-dd hh24:mi') snap_time. contact info@rampant. object_type.snap_id and wait. To license this script for a commercial purpose.count(*) > 1 group by h.cc ************************************************* set pages 999 set lines 80 break on snap_time skip 2 col col col col col col snap_time file_name object_type object_name wait_count time heading heading heading heading heading heading 'Snap Time' 'File Name' 'Object Type' 'Object Name' 'Wait Count' 'Time' format format format format format format a20 a40 a10 a20 999.file_name.file_id = ash. object_name.999 999.

session_state = 'ON CPU' and h.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.cc ************************************************* select TO_CHAR(h.cc ************************************************* select TO_CHAR(h. Use at your own risk.event_id = n.EVENT_ID and n.sample_time.session_state = 'ON CPU' and h.wait_time/100) "Total Wait Time (Sec)" from v$active_session_history h.---------- ash_wait_time.session_type = 'FOREGROUND' and h. ---------- ash_total_wait_time_dy.sample_time.session_type = 'FOREGROUND' and h.event_id = n. Use at your own risk.wait_class <> 'Idle' group by .'HH24').'HH24') "Hour". sum(h. v$event_name n where h.'Day') "Hour". To license this script for a commercial purpose. Sum(h.wait_class <> 'Idle' group by TO_CHAR(h.sample_time. contact info@rampant. contact info@rampant. €v$event_name n where h.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.EVENT_ID and n. To license this script for a commercial purpose.wait_time/100) "Total Wait Time (Sec)" from v$active_session_history h.

file_name Data File . SUM(h.time_waited) Total Time Waited from v$active_session_history h. v$event_name n where h.session_type = 'FOREGROUND' and h. To license this script for a commercial purpose. SUM(h. COUNT(*) Wait Number . Use at your own risk.event_id = n. contact info@rampant.session_state = 'ON CPU' and h.TO_CHAR(h.'HH24') = '12' and n. To license this script for a commercial purpose.event order by 2 DESC. dba_data_files f where h.wait_class <> 'Idle' group by h.file_id .sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.wait_time/100) "Wait Time (Sec)" from v$active_session_history h.EVENT_ID and to_char(h.current_file# = f.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.event "Wait Event".cc ************************************************* select h. Use at your own risk.sample_time.'Day'). contact info@rampant. ---------- ash_total_wait_time.sample_time.cc ************************************************* select f. ---------- ash_file_wait_time_dy.

wait_time + h.session_id = s.name order by 2 DESC. v$session s. s.event_id and e.event_id and e. Use at your own risk.sid. To license this script for a commercial purpose. v$event_name e where h. ---------- ash_total_wait_time_dy.time_waited) "total wait time" from v$active_session_history h. contact info@rampant.wait_class <> 'Idle' .wait_class <> 'Idle' group by e. Use at your own risk.event_id = e. To license this script for a commercial purpose.sid and e.group by f. SUM(h. ---------- ash_wait_time_sum. contact info@rampant.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.file_name order by 3 DESC.event_id = h.name "Wait Event".wait_time + h. v$event_name e where h.cc ************************************************* select s.time_waited) "Total Wait Time" from v$active_session_history h.username. sum(h.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.cc ************************************************* select e.

---------- ash_hot_objects.username order by 3. contact info@rampant. To license this script for a commercial purpose. s. v$event_name e where h. dba_objects o.and s. o.event_id = h.event_id and e.time_waited) "total wait time" from v$active_session_history h. Use at your own risk. o.sid.username IS NOT NULL group by s.owner.wait_class <> 'Idle' group by o. ---------- ash_latch.object_type order by 4 DESC. SUM(h. o.object_id and e.cc ************************************************* select o. To license this script for a commercial purpose.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.object_name.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.object_type. o.owner.current_obj# = o. Use at your own risk.object_name.wait_time + h.cc ************************************************* break on begin_interval_time skip 1 column begin_interval_time format a25 column latch_name format a40 . contact info@rampant.

1 and new. new.cc ************************************************* break on begin_interval_time skip 0 column stat_name format a25 select begin_interval_time.snap_id = ss.old. misses.snap_id = ss. sleeps from dba_hist_latch natural join dba_hist_snapshot where (misses + sleeps ) > 0 order by begin_interval_time.value) Difference from dba_hist_sys_time_model old.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.sql . dba_hist_sys_time_model new.snap_id and old.value . latch_name. sleeps DESC . misses DESC. Use at your own risk. To license this script for a commercial purpose. gets.stat_name. (new. ---------- ash_trend. dba_hist_snapshot ss where new. -- pid.stat_name like '%&stat_name%' order by begin_interval_time.select begin_interval_time. contact info@rampant.stat_name = old.snap_id .stat_name and new.

ADDR ORDER by a.osuser.program. To license this script for a commercial purpose.--------- ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. a.'Null') username.username.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.terminal.sid. contact info@rampant.'?'. a.'Detached'.spid. DECODE(a. b. Use at your own risk. b. b.username.pid. v$process b WHERE a. contact info@rampant.cc ************************************************* .a. a.serial# €FROM v$session a.PADDR = b.pid . SPOOL OFF CLEAR BREAKS CLEAR COLUMNS SET PAGES 22 TTITLE OFF PAUSE Press Enter to continue ---------- topsess.terminal) terminal.cc ************************************************* COLUMN terminal FORMAT a10 HEADING 'Terminal' COLUMN program FORMAT a30 HEADING 'Program' COLUMN pid FORMAT 9999 HEADING 'Process ID' COLUMN sid FORMAT 9999 HEADING 'Session ID' COLUMN osuser FORMAT A15 HEADING 'Operating System User' COLUMN spid FORMAT A7 HEADING 'OS Process ID' COLUMN serial# FORMAT 99999 HEADING 'Serial Number' SET LINES 132 PAGES 58 BREAK ON username COMPUTE COUNT OF pid ON username ttitle "Oracle Processes" SPOOL cur_proc SELECT NVL(a. To license this script for a commercial purpose. b. Use at your own risk.

v_$sesstat a. username. sys. nvl(b.statistic# and c. sid.p. username. sys. total_user_io amt_used.'physical writes'. sum(value) total_user_io from sys. round(100 * total_user_io/total_io. sys.v_$statname c.username.statistic# and p.name in ('physical reads'.v_$statname c.username. €€€€€€€€€€€€'physical writes direct'.2) pct_used from (select b.sid.v_$sesstat a.sid and c.sid=a. round(100 * total_user_io/total_io.select 'top physical i/o process' category. nvl(b.paddr (+) = b. sys. sys. 'physical writes direct (lob)') group by b. sys.statistic#=c.name) username. (select sum(value) total_io from sys.2) pct_used from (select b.v_$sesstat a where a.'physical writes'.p. 'physical writes direct'. 'physical reads direct (lob)'.v_$statname c. sys. 'physical reads direct'.sid sid. 'physical reads direct (lob)'. 'physical reads direct'.paddr and b.p. sum(value) total_user_io from sys. total_user_io amt_used. nvl(b.name) order by 3 desc).name) username.v_$session b.v_$bgprocess p .statistic#=c. sid.name in ('physical reads'.username. 'physical writes direct (lob)')) where rownum < 2 union all select 'top logical i/o process'.v_$bgprocess p where a.v_$session b.sid sid.

sid.username.name in ('session pga memory'.username.v_$statname c.'session uga memory') ) where rownum < 2 union all select 'top cpu process'. nvl(b.name) order by 3 desc).name in ('consistent gets'. €sys. nvl(b. nvl(b.statistic#=c.sid.'session uga memory') group by b.paddr (+) = b.2) from (select b.name) username. sys.statistic#=c.sid. username.v_$statname c. sys.paddr and b.v_$statname c.statistic# and c.paddr (+) = b. username.v_$bgprocess p where a.name in ('session pga memory'.p.statistic#=c. sys.'db block gets') group by b.sid=a.sid=a.v_$sesstat a where a. sid.sid and c.p. (select sum(value) total_mem from sys.v_$sesstat a where a. round(100 * total_user_mem/total_mem.statistic# and p. sum(value) total_user_mem from sys.statistic# and p.statistic#=c.statistic# and c. total_user_mem.name) order by 3 desc).where a. sys.'db block gets')) where rownum < 2 union all select 'top memory process'.name in ('consistent gets'.sid sid.sid and c.v_$session b. (select sum(value) total_io from sys. .paddr and b.username.p.v_$sesstat a.

name. nvl(b.sid=a.v_$sesstat a where a. (select sum(value) total_cpu from sys.************************************************* select * from (select b.'physical writes'.sid.0)) + sum(decode(c.value. (sum(decode(c. d.v_$bgprocess p where a.statistic# and c.null.'physical reads'.'physical writes direct (lob)'.value.username) user_name. -topsessdet.sid sid. sum(value) total_user_cpu from sys. sys.sid and c.sql -.machine machine_name.paddr (+) = b.************************************************* -. sys.sid sid.username.value.value. nvl(b. €€€€€sys.v_$statname c.p.v_$statname c.name = 'CPU used by this session' group by b.name.b.cc -.2) from (select b. €€€€€to_char(logon_time.name) username.Copyright © 2005 by Rampant TechPress -.p.This script is free for non-commercial purposes -.name.name.v_$session b.e.'physical reads direct (lob)'.0)) + sum(decode(c.To license this script for a commercial purpose. decode (b.name) order by 3 desc).name. -. --. b.with no warranties.value.0)) + sum(decode(c.v_$sesstat a.0)) .name.total_user_cpu.'physical writes direct'.statistic#=c.name = 'CPU used by this session' ) where rownum < 2.'mm/dd/yy hh:mi:ss pm') logon_time. Use at your own risk. round(100 * total_user_cpu/greatest(total_cpu.username.spid os_id. sys.statistic# and p.contact info@rampant.paddr and b.statistic#=c.username.1).0)) + sum(decode(c.

'sorts (disk)'.v_$statname c.name.0)) ) total_memory_usage.statistic# and b. 'consistent gets'. sum(decode(c. 1)) + sum (decode (c.value.name.v_$session b.name. (sum(decode(c.'consistent gets'.name.0)) recursive_cpu.name.0)) executions. 'physical reads direct (lob)'.'sorts (memory)'.value. 'physical writes direct (lob)'.'CPU used by this session'.0))+ sum(decode(c.'db block changes'.value.'parse time cpu'.name.name.value.name. sum(decode(c. 'physical reads direct'.0)) sum(decode(c.name in ('physical reads'.paddr and c.'recursive cpu usage'.'CPU used by this session'.value.value.'user commits'.'consistent gets'. (sum(decode(c.0)) disk_sorts.name.paddr (+) = b.'execute count'.v_$sesstat a.'consistent changes'.0)) parses.value.name.value.0)) rows_sorted. 'physical reads direct'. sys. value.name.name.'session uga memory'.'parse count (total)'.value. value.v_$bgprocess e where a.'physical reads direct'.name.value.0)) memory_sorts.name. sum(decode(c.sid and d.'parse time cpu'.name.0)) other_cpu.value.value. sys.name.0)) parse_cpu.value. sum(decode(c.'db block gets'.0)) commits. 0))) / (sum (decode (c. sys.name.'user rollbacks'. sum(decode(c.name.'session pga memory'.3)) hit_ratio. 'physical writes'.+ sum(decode(c. 100 100 * €€€€€(round ((sum (decode (c. 'physical reads'.0)) consistent_changes from sys.value. 0)) sum (decode (c. sum(decode(c.value.name. sys.0)) + sum(decode(c.name. value.0))) total_physical_io.value.addr = b.0)) physical_reads.'sorts (rows)'.0)) + sum(decode(c.name. sum(decode(c. sum(decode(c.statistic#=c.0)) + sum(decode(c. sum(decode(c.v_$process d.value.0)) consistent_gets.name.name. sum(decode(c. sum(decode(c.'recursive cpu usage'.name.value.value.value.name.0)) total_cpu. . 0)) ).0)) db_block_gets. €€€€€sum(decode(c.name.paddr and e.0)) rollbacks.'db block gets'.name. sum(decode(c.sid=a.'physical reads'.value.value.value.0)) ) total_logical_io. value.'consistent changes'. sum(decode(c.0)) sum(decode(c.value.name. 'physical writes direct'. sum(decode(c. 'db block gets'.

cc ************************************************* b. 'session uga memory'.v_$session b.username.2) average_wait_sec.'db block gets'.null. b. 'CPU used by this session'.username. 'consistent changes'. round((a.machine.c. . d. 'sorts (rows)'. 'user commits'. 'recursive cpu usage'. 'execute count' ) group by b.time_waited / 100). round((average_wait / 100).total_timeouts.sid. To license this script for a commercial purpose. 'parse time cpu'. decode(b.name. a. sys. 'session pga memory'.spid.b.a.'mm/dd/yy hh:mi:ss pm') order by 6 desc).max_wait / 100).name.total_waits.username). 'pmon timer'. sys. 'smon timer'. 'db block changes'. decode (b.b. 'rdbms ipc message'.v_$session_event a. 'sorts (memory)'. round((a.2) max_wait_sec FROM sys. event. 'consistent gets'. ---------- sesswaits. 'parse count (total)'.e.NULL.sid. €€€'sorts (disk)'.username) process_name. Use at your own risk. 'user rollbacks'.2) time_wait_sec.v_$bgprocess c SELECT €WHERE event NOT IN ('lock element cleanup'. contact info@rampant. to_char(logon_time.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.

p3raw FROM sys.p2raw. a.p1text.wait_time. 'parallel query dequeue wait'.c. 'pipe get'. 'slave wait'. a.paddr (+) order by 4 desc. sys. a. a.v_$bgprocess c SELECT €WHERE event NOT IN ('lock element cleanup'. a. 'SQL*Net message to client'. . a. a.p3text.event.b. 'dispatcher timer'.v_$session b.v_$session_wait a.Slaves'. 'SQL*Net more data to client'.username. 'PL/SQL lock timer'. 'pmon timer'.p3.p1.sid.paddr = c.sid = b. Use at your own risk.cc ************************************************* a. 'rdbms ipc message'. 'WMON goes to sleep' ) and event NOT LIKE 'DFS%' and event NOT LIKE 'KXFX%' €and a. a.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. €€'parallel query idle wait .p1raw. ---------- csesswaits. sys.'SQL*Net message from client'.p2text. contact info@rampant.sid and b. a.p2. 'SQL*Net break/reset to client'.username) process_name. a. 'virtual circuit status'. a. a.seconds_in_wait. 'Null event'. To license this script for a commercial purpose.NULL.state.name. a. decode(b.

name. 1)) + sum (decode (c. 'SQL*Net message from client'. to_char(logon_time. 'slave wait'.sid and b. value. .name.sid sid.cc ************************************************* b.paddr (+) order by 4 desc.b. 'db block gets'. €€sys.'mm/dd/yy hh:mi:ss pm') logon_time. sys. d. €€€€€€'PL/SQL lock timer'. 'Null event'.3)) hit_ratio select from sys. value.name.name. 'virtual circuit status'.username. 'parallel query dequeue wait'.paddr = c. 'physical reads'.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.v_$session b. 'SQL*Net more data to client'. 'dispatcher timer'. 'physical reads direct'.spid os_id. value.'smon timer'. 0))). 'SQL*Net break/reset to client'.e.name.sid = b.null. 'consistent gets'. decode (b. 'pipe get'. 0))) / (sum (decode (c. To license this script for a commercial purpose. contact info@rampant. 0)) sum(decode (c.machine machine_name.Slaves'.v_$statname c. value. 0)) sum (decode (c.v_$sesstat a.name. 'parallel query idle wait . value. 'SQL*Net message to client'. 'WMON goes to sleep' ) and event NOT LIKE 'DFS%' and event NOT LIKE 'KXFX%' and a. 'physical reads direct (lob)'. ---------- sesshitrate.username) user_name. Use at your own risk. b. 100 .100 * (round ((sum (decode (c.

username . b.Copyright © 2005 by Rampant TechPress -.'SYSTEM') order by 3 desc.sid.Copyright © 2005 by Rampant TechPress -.parsing_user_id=b.sid and d.buffer_gets.statistic# and b.sql -. --.paddr and e. d.sid=a. -memhog.sys.username).statistic#=c. 'consistent gets') group by €€€€b.username not in ('SYS'.'mm/dd/yy hh:mi:ss pm') order by 6 desc.username.v_$bgprocess e where a. 100 .paddr (+) = b. 'physical reads direct (lob)'.1). -.null. sys.name in ('physical reads'.************************************************* -.addr = b.This script is free for non-commercial purposes -.************************************************* select sql_text . 'db block gets'. to_char(logon_time. -sqlhitrate. decode (b.paddr and c.user_id and b.contact info@rampant.sql -.name. sys. Use at your own risk.To license this script for a commercial purpose.e.round(100 * a.v_$sqlarea a.cc -.all_users b where a.************************************************* -.disk_reads/greatest(a.spid. 'physical reads direct'.2) hit_ratio from sys.This script is free for non-commercial purposes . b.with no warranties.v_$process d.machine.b. 'physical writes direct (lob)'.

sys. (select sum(value) total_mem from sys.statistic#=c.username.v_$session b.v_$bgprocess p where a. To license this script for a commercial purpose. Use at your own risk.username.name in ('session pga memory'.paddr (+) = b. nvl(b.sid and c.cc ************************************************* select name. nvl(b.'session uga memory')) order by 3 desc.v_$sysstat where .paddr and b.p.2) mem_used_in_kb.2) mem_percent select from (select b. sum(value) total_user_mem from sys.sid=a.statistic#=c. round(total_user_mem/1024. sys. Use at your own risk.name in ('session pga memory'. value from sys.statistic# and c.name)). round(100 * total_user_mem/total_mem. contact info@rampant. username.v_$statname c. contact info@rampant.name) username.v_$sesstat a where a.v_$sesstat a.sid sid.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.statistic# and p. ---------- bgact.------ with no warranties.v_$statname c. sys. sys. To license this script for a commercial purpose.'session uga memory') group by b.sid.cc ************************************************* sid.p.

sql -. -rolldet.************************************************* -.This script is free for non-commercial purposes -. extends.contact info@rampant.************************************************* select name.with no warranties. xacts.v_$archived_log where sysdate .'mm/dd/yy') completion_time.completion_time < 31 group by to_char(completion_time. Use at your own risk.'mm/dd/yy') order by 1 desc. 'summed dirty queue length'. round ((rssize / 1024). 2) size_kb. contact info@rampant. count(*) log_count from sys.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. --. ---------- archhist. . shrinks. writes. gets. 'write requests')) or (name like '%redo%') order by 1. status.(name like '%DBWR%' or name in ('dirty buffers inspected'. -.cc -. waits. Use at your own risk.cc ************************************************* select to_char(completion_time. To license this script for a commercial purpose.To license this script for a commercial purpose.Copyright © 2005 by Rampant TechPress -.

To license this script for a commercial purpose. select . a.username is not null and a. round((a.2. 2) hw_kb €from sys.cc ************************************************* a. a.v_$session_wait_class a.5 desc ---------- 10g_last10waits.2) wait_time_secs. ---------- 10g_sesswaitclass.seq# wait_number.wait_class wait_class. contact info@rampant.round ((hwmsize / 1024).usn) €order by name. sys.2) time_waited_secs select from sys.total_waits.wait_class.v_$rollstat a. Use at your own risk.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. To license this script for a commercial purpose.sid and b. a. Use at your own risk.cc ************************************************* a.sid = a. a.v_$session b where b.event.time_waited / 100).p1text.wait_time / 100).v_$rollname b €where (a. round((a.username. b.usn = b. c. contact info@rampant.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.sid. sys.wait_class != 'Idle' order by 1.

contact info@rampant.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.a. contact info@rampant.stat_name.v_$session b where a. To license this script for a commercial purpose.3 € ---------- 10g_usertime. sys.sid and b.sid.sid = < enter SID > order by 4 desc ---------- histsesstime. a. sys. a.sid = 249 order by 1.v_$sess_time_model a. a.v_$session_wait_history a.p1.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. a.v_$event_name c where a. a. sys.value / 1000000).cc ************************************************* a.v_$session b.username.event# and b.p3text. Use at your own risk.3) time_secs select from sys.sid and a.sid = b.sid = b. To license this script for a commercial purpose.p3 from sys. b. round((a.event# = c.p2.cc ************************************************* select . Use at your own risk.p2text.

event# = b.c.session_type.cc ************************************************* select event "Event Name".event# and a. a. sess_time.sess_id.2) pct_time_waited from (select a. contact info@rampant.user_id = c.time_waited) sess_time from sys. (select sum(a.total_waits.event# = b.v_$event_name b. username.v_$active_session_history a.0) waits . Use at your own risk.c. decode(session_type. program.program program.event_name event .event# and sample_time > '23-SEP-04 12:00:00 AM' and sample_time < '25-SEP-04 12:10:00 AM' ) order by 5 desc ---------- bg_event_int_10g. avgwait "Avg Wait (ms)". sys.session_type.total_waits . time "Wait Time (s)".dba_users c where a. To license this script for a commercial purpose. e.v_$active_session_history a.'BACKGROUND'.user_id and sample_time > '23-SEP-04 12:00:00 AM' and sample_time < '25-SEP-04 12:00:00 AM' group by a.program).username). round(100 * (sess_time / total_time).session_id. waits "Waits".v_$event_name b where a. sum(a.username) username. sys. decode(session_type. waitclass "Wait Class" from (select e. a. timeouts "Timeouts".nvl(b.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.'BACKGROUND'.session_id sess_id. sys.time_waited) total_time from sys.

instance_number(+) = &pInstNum and e. 'table scans (rowid ranges)'.time_waited_micro .cc ************************************************* select name. 0.total_waits.total_timeouts .dbid = &pDbId and b. 'table fetch by rowid'. to_number(NULL) .sql -. 0)).nvl(b..wait_class <> 'Idle' ) order by time desc.0))/1000000 time .instance_number = &pInstNum and b.nvl(b. 'table scans (long tables)'. e.total_waits. 'table fetch continued row') order by 1. ((e. decode ((e.nvl(b.snap_id = &pEndSnap and b.nvl(b. e.event_id(+) = e.0))/1000) / (e. 'table scans (direct read)'.0) timeouts .total_timeouts.************************************************* . dba_hist_bg_event_summary e where b.time_waited_micro .total_waits .total _waits .nvl(b.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.v_$sysstat where name in ('table scans (cache partitions)'.snap_id(+) = &pBgnSnap and e.event_id and e.total_waits > nvl(b. waits desc ---------- globaccpatt.0)) ) avgwait .time_waited_micro. To license this script for a commercial purpose.total_waits.wait_class waitclass from €€€€dba_hist_bg_event_summary b .0) and e. 'table scans (short tables)'. Use at your own risk. -chaincnt.time_waited_micro. contact info@rampant. value from sys.dbid(+) = &pDbId €€€€€€€€and e. (e.

Use at your own risk.v_$sysstat where name in ('table fetch by rowid'. ---------- chainpct. contact info@rampant. To license this script for a commercial purpose.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. (select sum(value) as total_fetches from sys. Use at your own risk.cc ************************************************* count(*) select from sys.v_$sysstat a where name = 'table fetch continued row'). contact info@rampant.cc ************************************************* chained_rows.cc ************************************************* select round(100 * (chained_row_fetches / total_fetches).sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.-------- Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. 'table scan rows gotten')). To license this script for a commercial purpose. To license this script for a commercial purpose. Use at your own risk.sql .2) pct_chain_access from (select value as chained_row_fetches from sys.tab$ where chncnt > 0. contact info@rampant. ----------- chaintables.

99 column table_name heading 'Table Name' column chain_cnt heading 'Chained Rows' column num_rows heading 'Row Count' set pages 47 set feedback off ttitle 'Chained Rows Report' spool chained_rows select table_name.sql -. Use at your own risk. tablespace_name select from sys.3.segment_name.************************************************* .cc ************************************************* owner. contact info@rampant. next_extent. -objdef.NULL.-. extents.MRA -column "Chain Percent" format 999. max_extents.2.tables must have been analyzed -.' partition_name) segment_name. spool off ttitle off ---------- maxext8. chain_cnt/num_rows*100 "Chain Percent" fr om dba_tables where chain_cnt>1 and owner not in ('SYS'. decode(partition_name. To license this script for a commercial purpose.chain_cnt.segment_name '.FUNCTION: Show percentage of chained rows -.'SYSTEM'). segment_type.extents <= 5 and segment_type <> 'CACHE' order by 1. initial_extent. num_rows.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.dba_segments where max_extents .

segment_name.tablespace_name.tablespace_name = c. a.tablespace_name = b. a. select .dba_segments a.tablespace_name) group by a. a.dba_free_space b where a.owner.dba_free_space c where a. contact info@rampant.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.owner. hwm highwater_mark. a.tablespace_name.cc ************************************************* select a.tablespace_name = c.tablespace_name and b.cc ************************************************* /*+ RULE */ owner.segment_type. a.segment_type. To license this script for a commercial purpose.segment_name.-------- Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.tablespace_name and a.bytes) max_contig_space from sys. round(bytes/1024.next_extent ---------- tabreorg8. Use at your own risk. Use at your own risk. a.next_extent. avg_used_blocks. contact info@rampant. a.next_extent > (select max(bytes) from sys. max(c. empty_blocks. a. segment_type. sys. To license this script for a commercial purpose. blocks. num_rows.2) table_kb. segment_name table_name.

bytes. decode(greatest(max_free_space next_extent. segment_type. num_rows.0) / greatest(nvl(hwm.blocks blocks.ts$ c where ( a.name €union all €select a.blocksize.0.round((b. segment_name.2) max_extent_pct.1) ).round((b.0.greatest(round(100 * (nvl(hwm .1)). b. round(100 * (nvl(b.partition_name.max_extents). a.owner = b. b.owner owner.' b. next_extent.1.0) / greatest(nvl(b.2) .0.extents extents.blocksize.dba_all_tables b. sys.num_rows * (1 + (b.2).1 hwm. segment_type.avg_used_blocks.1.tablespace_name = c.num_rows * (1 + (b.dba_segments a.avg_row_len * b.empty_blocks empty_blocks.1).0) block_inefficiency.owner owner.empty_blocks .avg_row_len * b. decode(round((b.pct_free/100))) / c.max_extents max_extents. round(100 * (nvl(b.0)) + 2 avg_used_blocks. max_extents.avg_row_len * num_rows * (1 + (pct_free/100))) / c.b.1)).blocks blocks.next_extent next_extent.owner ) and ( segment_name = table_name ) and ( ( segment_type = 'TABLE ) ) and b.empty_blocks . b.1).num_rows.0)) + 2 avg_used_blocks.1). a.2) chain_pct.0).chain_cnt. segment_name '.blocks .blocksize.'n'.empty_blocks empty_blocks.0). a.b. chain_pct. a.0) / greatest(nvl(b. sys. extents.1 hwm.num_rows. a.avg_row_len * num_rows * (1 + (pct_free/100))) / c.blocks .blocksize.'y') can_extend_space.tablespace_name o_tablespace_name from sys. round(100 * (a.0). o_tablespace_name tablespace_name from (select a.pct_free/100))) / c.num_rows. a.extents / a. decode(round((b. max_extent_pct. bytes.chain_cnt. max_free_space. b. b.

chain_pct, a.extents extents, round(100 * (a.extents / a.max_extents),2) max_extent_pct, a.max_extents max_extents, b.next_extent, b.tablespace_name o_tablespace_name from sys.dba_segments a, sys.dba_tab_partitions b, sys.ts$ c, sys.dba_tables d where ( a.owner = b.table_owner ) and ( segment_name = b.table_name ) and ( ( segment_type = TABLE PARTITION' ) ) and b.tablespace_name = c.name and €d.owner = b.table_owner and d.table_name = b.table_name and a.partition_name = b.partition_name), ( select tablespace_name f_tablespace_name, max(bytes) max_free_space from sys.dba_free_space group by tablespace_name) where f_tablespace_name = o_tablespace_name and greatest(round(100 * (nvl(hwm - avg_used_blocks,0) / greatest(nvl(hwm,1),1) ),2),0) > 25 order by 10 desc, 1 asc,2 asc

-idxreorg8.sql -- ************************************************* -- Copyright © 2005 by Rampant TechPress -- This script is free for non-commercial purposes -- with no warranties. Use at your own risk. --- To license this script for a commercial purpose, -- contact info@rampant.cc -- ************************************************* select /*+ RULE */ owner, segment_name index_name, segment_type, round(bytes/1024,2) index_kb, num_rows, clustering_factor, blevel, blocks, max_extent_pct, extents, max_extents, decode(greatest(max_free_space next_extent,0),0,'n','y') can_extend_space,

next_extent, max_free_space, o_tablespace_name from (select a.owner owner, segment_name, segment_type, bytes, num_rows, b.clustering_factor, b.blevel, a.blocks blocks, a.extents extents, round(100 * (a.extents / a.max_extents),2) max_extent_pct, a.max_extents max_extents, b.next_extent next_extent, b.tablespace_name o_tablespace_name from sys.dba_segments a, sys.dba_indexes b, €sys.ts$ c where ( a.owner = b.owner ) and ( segment_name = index_name ) and ( ( segment_type = 'INDEX' ) ) and b.tablespace_name = c.name €union all €select a.owner owner, segment_name '.' b.partition_name, segment_type, bytes, b.num_rows, b.clustering_factor, b.blevel, a.blocks blocks, a.extents extents, round(100 * (a.extents / a.max_extents),2) €€max_extent_pct, a.max_extents max_extents, b.next_extent, b.tablespace_name o_tablespace_name from sys.dba_segments a, sys.dba_ind_partitions b, sys.ts$ c, sys.dba_indexes d where ( a.owner = b.index_owner ) and ( segment_name = b.index_name ) and ( ( segment_type = INDEX PARTITION' ) ) and b.tablespace_name = c.name and d.owner = b.index_owner and d.index_name = b.index_name and a.partition_name = b.partition_name), ( select tablespace_name f_tablespace_name, max(bytes) max_free_space

from sys.dba_free_space group by tablespace_name) where f_tablespace_name = o_tablespace_name order by 1,2;

----------

cfb_ratio.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. Use at your own risk. To license this script for a commercial purpose, contact info@rampant.cc *************************************************

-- Mike Ault -column table_name format a20 heading 'Table Name' column index_name format a20 heading 'Index Name' column dirty_blocks heading 'Dirty Blocks' column clustering_factor heading 'Clustering Factor' column cfb_ratio heading 'Clustering Factor To Blocks Ratio' format 99,999.99 column owner format a15 heading 'Owner' ttitle 'Clustering Factor to Block Ratio Report' set lines 132 verify off pages 55 feedback off break on owner on table_name spool rep_out\&&database\cfb_ratio select t.owner,t.table_name,i.index_name, t.num_rows, t.blocks dirty_blocks,i.cl ustering_factor, i.clustering_factor/decode(t.blocks,0,decode(i.clustering_factor,0,1,i.clusterin g_factor),t.blocks) cfb_ratio, i.blevel from dba_tables t, dba_indexes i where t.owner=i.table_owner and t.table_name=i.table_name and t.owner not in ('SYS','SYSTEM','DBAUTIL','OUTLN','DBSNMP','SPOTLIGHT','PERFS TAT','RMAN','IWATCH') order by t.owner,i.clustering_factor/decode(t.blocks,0,decode(i.clustering_facto r,0,1,i.clustering_factor),t.blocks) desc,t.table_name,i.index_name / spool off set lines 80 pages 22 feedback on verify on clear columns ttitle off rem and i.clustering_factor/decode(t.blocks,0,decode(i.clustering_factor,0,1,i.c lustering_factor),t.blocks)>10

-toptables.sql -- *************************************************

disk_reads) disk_reads . table_name. table_owner.name table_name .cc ************************************************* select table_owner "table owner".command_type in (2.owner . 2. 'insert ' . sum(a. sum(a.rows_processed) rows_processed €from sys. -- largescan9i. sum(a. sys. c. gets "buffer gets". c.name and c.command_type .buffer_gets) gets .7.v_$object_dependency b .'select '. 26. €€€€€€€€€€gets. table_name "table name".name ) ) where rownum <= 100.v_$sql a .-------- Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. command. rows_processed "rows processed" from (select distinct executions. rows_processed.executions) executions .'SYSTEM') €group by a.owner table_owner.sql .a. c. contact info@rampant.command_type . command "command issued". sys.to_owner = c. 3.'table lock ') command . To license this script for a commercial purpose.26)and b. disk_reads "disk reads". 'delete ' .type = 'table' and c. 'update ' . 7.owner and b.executions "executions".address and b. disk_reads €from (select decode (a.6. 0 . c. 6. sum(0 .owner not in ('SYS'.from_address = a.v_$db_object_cache c €where a. Use at your own risk.3.to_name= c.

executions. b. size_kb.object_name table_name. reference_count. sum(c.dba_segments b.hash_value ) statement_count. 1. -- awr_sql_object_char.cc ************************************************* select table_owner. executions * reference_count total_scans from (select a.hash_value = c.bytes / 1024 size_kb.segment_name and b. count( distinct a. Use at your own risk. b.bytes / 1024. a.hash_value and b. contact info@rampant. table_name.object_name (+) = b.--------- ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. b. 2 ).segment_type order by 4 desc.segment_type IN ('TABLE'. To license this script for a commercial purpose.object_owner (+) = b. a. table_type.operation LIKE '%TABLE%' and a.object_owner.v_$sql c where a.bytes / 1024 > 1024 group by a.object_name.operation. count( * ) reference_count from sys. statement_count. a. b.owner and a. sys.segment_type table_type.options = 'FULL' and a.executions ) executions.object_owner table_owner. sys. 'TABLE PARTITION') and a.v_$sql_plan a.sql .

object_type c2. p.cc ************************************************* accept tabname prompt Enter Table Name: col c0 heading Begin Interval time col c1 heading Owner format a8 format a10 . contact info@rampant.object_owner <> 'SYS' group by p.999. Use at your own risk. p. To license this script for a commercial purpose.4 desc .999 format 9.object_owner. p. Use at your own risk. avg(p.object_name order by 1. ---------- awr_sql_object_char_detail.999 col c1 heading Owner col c2 heading Object Type col c3 heading Object Name col c4 heading Average CPU Cost col c5 heading Average IO Cost break on c1 skip 2 break on c2 skip 2 select p.object_name is not null and p.cc ************************************************* format a13 format a15 format a25 format 9. contact info@rampant.object_name €€c3.--------- ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.object_owner c1.2. p. avg(p.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.io_cost) c5 from dba_hist_sql_plan p where p.999.object_type. To license this script for a commercial purpose.cpu_cost) c4.

3 desc .'mm-dd hh24').999.999 99.begin_interval_time.'mm-dd hh24') c0.object_owner c1.object_name is not null and p. ---------- awr_nested_join_alert.cc ************************************************* c1 c2 c3 c4 c5 heading heading heading heading heading Date Nested Loops Count Rows Processed Disk Reads CPU Time format format format format format a20 99.cpu_cost) c4. dba_hist_snapshot sn where p.999 col col col col col .2. p. p.999.object_owner.999.col col col col c2 c3 c4 c5 heading heading heading heading Object Type Object Name Average CPU Cost Average IO Cost format format format format a10 a15 9.begin_interval_time. contact info@rampant.io_cost) €€€€€€€€€€€€€€€€€c5 from dba_hist_sql_plan p.999.snap_id group by to_char(sn. To license this script for a commercial purpose. p.999.object_name c3.object_name order by 1. dba_hist_sqlstat st.object_name = 'CUSTOMER_DETS' and p.object_type.999 break on c1 skip 2 break on c2 skip 2 select to_char(sn.sql_id and st. p.999 9.999 99.999 99.object_owner <> 'SYS' and p.sql_id = st. Use at your own risk.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.999.object_type c2. avg(p.snap_id = sn. avg(p. p. p.

snap_id = s.cpu_time_delta) c5 from dba_hist_snapshot sn.disk_reads_delta) c4. sum(t. count(*) c2.'yy-mm-dd hh24') c1.snap_id and .object_name €€€c1.sql_id and t.snap_id and p.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. dba_hist_sql_plan p.begin_interval_time.sql_id and sn.999.cc ************************************************* col c0 heading Begin Interval time format a8 col c1 heading Index Name format a20 col c2 heading Disk Reads format 99.999 select to_char(s.begin_interval_time. contact info@rampant.999.sql_id = p. ---------- awr_sql_index. sum(st. sum(st. Use at your own risk.disk_reads_total) c2.999 col c3 heading Rows Processed format 99. sum(st. p. dba_hist_sqlstat t. To license this script for a commercial purpose.snap_id = st.accept nested_thr char prompt Enter Nested Join Threshold: ttitle Nested Join Threshold &nested_thr select to_char(sn.operation = NESTED LOOPS having count(*) > &hash_thr group by begin_interval_time. dba_hist_snapshot s where p. sum(t.sql_id = t. dba_hist_sqlstat st where st.rows_processed_total) c3 from dba_hist_sql_plan p.'mm-dd hh24') c0.rows_processed_delta) €€€€€€€€€€€€€€€€c3.

sql_id and s.begin_interval_time. u. -awr_sql_index_access. -.object_owner <> 'SYS' and p.'yy-mm-dd hh24') order by 1 ) r.Free for non-commercial use! -. dba_hist_sqlstat s.c2 c3.sql_id = s. f.c1. dba_hist_snapshot sn .c2 c4 from ( select to_char(sn.'mm-dd hh24').object_name order by c0. e-mail info@rampant. dba_hist_snapshot sn where p.'yy-mm-dd hh24') c1.p.begin_interval_time. p.snap_id group by to_char(sn. ( select to_char(sn.999 Full Scans format 999.begin_interval_time.sql --************************************************* -.begin_interval_time. count(1) c2 from dba_hist_sql_plan p. dba_hist_sqlstat s.snap_id = sn.c2 c2.cc -. r.999 select r.object_type like '%INDEX%' group by to_char(s.************************************************ col col col col c1 c2 c3 c4 heading heading heading heading Begin Index Index Index Interval Time format a20 Range Scans format 999.Copyright © 2005 by Rampant TechPress Inc.To license.operation like '%INDEX%' and p.options like '%RANGE%' and p.'yy-mm-dd hh24') c1.c2 desc .c1 c1.999 Unique Scans format 999. count(1) €€c2 from dba_hist_sql_plan p.

snap_id = sn.object_owner <> 'SYS' and p.c1 and r.'yy-mm-dd hh24') c1. ---------- awr_sql_object_avg_dy.c1 = f.options like '%FULL%' and p. dba_hist_snapshot sn where p. To license this script for a commercial purpose.999.cc ************************************************* format a30 format a15 format 99.begin_interval_time. ( select to_char(sn.'yy-mm-dd hh24') order by 1 ) u.'yy-mm-dd hh24') order by 1 ) f where r.c1 = u. dba_hist_sqlstat s.operation like '%INDEX%' and p.options like '%UNIQUE%' and p.sql_id = s.c1 .999 col c1 heading Object Name col c2 heading Week Day col c3 heading Invocation Count .sql_id and s.begin_interval_time.snap_id group by to_char(sn.sql_id = s.snap_id group by to_char(sn.object_owner <> 'SYS' and p.sql_id and s.snap_id = sn. count(1) c2 from dba_hist_sql_plan p.begin_interval_time.operation like '%INDEX%' and p.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. contact info@rampant. Use at your own risk.where p.

3.4.'Sunday') c2.snap_id group by p.'Friday'.object_owner <> 'SYS' and p.1.'Thursday'.2. c3 from ( select p.object_name. To license this script for a commercial purpose.999.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.object_name c1.snap_id = sn. to_char(sn. to_char(sn.break on c1 skip 2 break on c2 skip 2 select decode(c2. c1.'d') order by c2.5.c1 ) .cc ************************************************* col c1 heading Begin Interval time format a20 col c2 heading Search Columns format 999 col c3 heading Invocation Count format 99. ---------- usage_hr.'Satu rday'. count(1) c3 from dba_hist_sql_plan p. contact info@rampant. dba_hist_snapshot sn where p. dba_hist_sqlstat s.999 break on c1 skip 2 accept idxname char prompt Enter Index Name: ttitle select Invocation Counts for index &idxname .'Tuesday'.end_interval_time.'Monday'. Use at your own risk.end_interval_time.6.7.'Wednesday'.sql_id = s.'d') c2.sql_id and s.

'yy-mm-dd hh24') c1.begin_interval_time.to_char(sn.cc ************************************************* ttile Table Access Operation Counts Per Snapshot Period col col col col c1 c2 c3 c4 heading heading heading heading Begin Interval time format a20 Operation format a15 Option format a15 Object Count format 999. dba_hist_snapshot sn where p.snap_id and p.options c3. p.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. To license this script for a commercial purpose.snap_id group by to_char(sn.sql_id and sn.object_name = &idxname' group by begin_interval_time.snap_id = sn. count(*) c3 from dba_hist_snapshot sn. ---------- awr_access_counts.snap_id = st.operation.begin_interval_time.sql_id and s.'yy-mm-dd hh24'). dba_hist_sqlstat s. Use at your own risk. p.'yy-mm-dd hh24') c1.operation c2.999 break on c1 skip 2 break on c2 skip 2 select to_char(sn.sql_id = s. contact info@rampant. count(1) c4 from dba_hist_sql_plan p.search_columns.sql_id = p.search_columns c2. dba_hist_sql_plan p.object_owner <> 'SYS' and p. p.options . p. p.begin_interval_time. dba_hist_sqlstat st where st.

f.sql_id and s.c2 €c3 from ( select to_char(sn.options like '%INDEX%' and p.'yy-mm-dd hh24') c1. dba_hist_snapshot sn where p.object_owner <> 'SYS' and p.999 col c3 heading Full Table Scans format 999. dba_hist_snapshot sn where p. Use at your own risk. count(1) €€€€€€€€€€€€€€€€€€€€€€€€€c2 from dba_hist_sql_plan p.sql_id = s.c2 c2. i. ---------- awr_sql_full_scans.begin_interval_time.cc ************************************************* col c1 heading Begin Interval Time format a20 col c2 heading Index Table Scans format 999. dba_hist_sqlstat s.999 select i.'yy-mm-dd hh24') order by 1 ) i.order by 1. dba_hist_sqlstat s.object_owner <> 'SYS' and .begin_interval_time.3. To license this script for a commercial purpose. contact info@rampant.'yy-mm-dd hh24') c1.snap_id group by to_char(sn.operation like '%TABLE ACCESS%' and p.c1 c1.2. ( select to_char(sn.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.begin_interval_time. count(1) c2 from dba_hist_sql_plan p.snap_id = sn.

contact info@rampant. dba_hist_snapshot sn.c1 . dba_hist_sqlstat s.c1 = f. Use at your own risk.cc ************************************************* ttile Large Full-table scans Per Snapshot Period col c1 heading Begin Interval time col c4 heading FTS Count break on c1 skip 2 break on c2 skip 2 select to_char(sn.snap_id = sn.object_name = o.begin_interval_time.begin_interval_time. To license this script for a commercial purpose.options = 'FULL' and p.'yy-mm-dd hh24') c1.sql_id = s. dba_segments o where p.sql_id = s.owner and p.sql_id format a20 format 999.options like '%FULL%' and p.p.object_owner = o.999 . count(1) €c4 from dba_hist_sql_plan p.segment_name and o.'yy-mm-dd hh24') order by 1 ) f where i.blocks > 1000 and p.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.operation like '%TABLE ACCESS%' and p.snap_id group by to_char(sn.sql_id and s. ---------- awr_full_table_scans.operation like '%TABLE ACCESS%' and p.object_owner <> 'SYS' and p.

snap_id group by to_char(sn.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.begin_interval_time.object_owner = o.snap_id = sn.snap_id = sn.begin_interval_time. Use at your own risk.sql_id = s.999 . contact info@rampant.sql_id and s.object_name = o. count(1) c2 from dba_hist_sql_plan p.object_owner <> 'SYS' and p.cc ************************************************* ttile Large Tabe Full-table scans Averages per Hour col c1 heading Day Hour col c2 heading FTS Count break on c1 skip 2 break on c2 skip 2 select to_char(sn.operation like '%TABLE ACCESS%' and p. dba_hist_sqlstat s.and s.owner and p.'yy-mm-dd hh24') order by 1. To license this script for a commercial purpose. ---------- awr_sql_access_hr. dba_segments o where p.'hh24') order by 1. dba_hist_snapshot sn. format a20 format 999.blocks > 1000 and p.begin_interval_time.options like '%FULL%' and p.segment_name and o.'hh24') c1.snap_id group by to_char(sn.

sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.'day') order by 1.'day') c1.object_name = o.999 ------- awr_sql_scan_sums.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.cc ************************************************* ttile Large Table Full-table scans Averages per Week Day col c1 heading Week Day col c2 heading FTS Count break on c1 skip 2 break on c2 skip 2 select to_char(sn. To license this script for a commercial purpose.options like '%FULL%' and p.blocks > 1000 and p.---------- awr_sql_access_day. format a20 format 999.object_owner <> 'SYS' and p. count(1) c2 from dba_hist_sql_plan p. dba_hist_sqlstat s. Use at your own risk.operation like '%TABLE ACCESS%' and p. dba_segments o where p. Use at your own risk.begin_interval_time. .sql_id and s. contact info@rampant.snap_id group by to_char(sn.owner and p. dba_hist_snapshot sn.object_owner = o.snap_id = sn.segment_name and o.sql_id = s.begin_interval_time.

( select to_char(sn.object_owner = o. dba_hist_snapshot sn.owner and p.begin_interval_time. dba_hist_sqlstat s.object_name = o. dba_segments o where p.contact info@rampant.'yy-mm-dd hh24') order by 1 ) f.999 select f. count(1) c2 from dba_hist_sql_plan p.begin_interval_time.999 999.To license this script for a commercial purpose.-.options like '%FULL%' and p.sql_id = s.object_owner <> 'SYS' and p.'yy-mm-dd hh24') c1. s. dba_hist_snapshot sn.c2 c2. dba_segments o where p. dba_hist_sqlstat s.c2 c4 from ( select to_char(sn.object_name = o.999 999.snap_id group by to_char(sn.begin_interval_time.c2 c3.object_owner = o.snap_id = sn.c1 c1.'yy-mm-dd hh24') c1.sql_id and s. count(1) €€€€€€€€€€€€€€€€€€€€€€€€€€c2 from dba_hist_sql_plan p.************************************************* col col col col c1 c2 c3 c4 heading heading heading heading Begin Large Small Total Interval Time €€€€€€€€format Table Full Table Scans format Table Full Table Scans format Index Scans €€€€€€€€€€€format a20 999.cc -. i.object_owner <> 'SYS' and p.operation like '%TABLE ACCESS%' and p.owner and p. -.segment_name . f.blocks > 1000 and p.segment_name and o.

sql_id and s. Use at your own risk.operation like '%INDEX%' and p. To license this script for a commercial purpose.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. contact info@rampant.cc ************************************************* format a20 col c1 heading Begin Interval Time col c2 heading Index Table Scans format 999.snap_id group by to_char(sn.sql_id = s.object_owner <> 'SYS' and p. count(1) €€€€€€€€€€€€€€€€€€c2 from dba_hist_sql_plan p.begin_interval_time.sql_id = s.c1 and f.sql_id and s.begin_interval_time.c1 c1.c2 c2.begin_interval_time. dba_hist_snapshot sn where p. ---------- awr_sql_full_scans_avg_dy.operation like '%INDEX%' and p. dba_hist_sqlstat s.snap_id = sn.999 col c3 heading Full Table Scans format 999.c1 = i. ( select to_char(sn.c2 c3 .'yy-mm-dd hh24') c1.'yy-mm-dd hh24') order by 1 ) i where f.'yy-mm-dd hh24') order by 1 ) s. f.and o.c1 = s.snap_id = sn.c1 .blocks < 1000 and p.snap_id group by to_char(sn.999 select i. i.

To license this script for a commercial purpose.begin_interval_time.object_owner <> 'SYS' and p.sql_id = s.'day') c1. dba_hist_snapshot sn where p. . Use at your own risk.'day') c1.sql_id and s.sql_id = s. dba_hist_sqlstat s.'day') order by 1 ) f where i.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.snap_id group by to_char(sn. dba_hist_snapshot sn where p. dba_hist_sqlstat s.snap_id group by to_char(sn. ( select to_char(sn.operation like '%TABLE ACCESS%' and p. count(1) c2 from dba_hist_sql_plan p.c1 .c1 = f.sql_id and s.begin_interval_time.from ( select to_char(sn.options = 'FULL' and p. -------- ash_hot_objects.'day') order by 1 ) i.begin_interval_time.begin_interval_time. count(1) c2 from dba_hist_sql_plan p.snap_id = sn.options like '%INDEX%' and p.object_owner <> 'SYS' and p.snap_id = sn.operation like '%TABLE ACCESS%' and p.

owner. o.cc ************************************************* db_size_in_mb .wait_time + h. lp_size_in_mb. dba_objects o.bytes) / 1024 / 1024.object_name. o. 2) db_size_in_mb from sys.event_id = h.0) db_caches from sys. sp_size_in_mb.object_id and e. SUM(h. lb_size_in_mb.current_obj# = o.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. v$event_name e where h.wait_class <> 'Idle' group by o. ---------- sgasize. jp_size_in_mb select from (select round (max(a. db_caches db_caches_mb.name like '%k_cache_size'). (select . To license this script for a commercial purpose. o. Use at your own risk.name = 'buffer_cache')).-. 2).v_$sgastat a €where (a. contact info@rampant.event_id and e.object_name.db_caches db_buffers_in_mb.time_waited) "total wait time" from v$active_session_history h.value) / 1024 / 1024. o. (select nvl(round (sum (b.object_type.owner.name = 'db_block_buffers' or a.v_$parameter b €where b. fixed_size_in_mb.object_type order by 4 DESC.************************************************* select o.cc -.contact info@rampant.

round (sum (b.bytes) / 1024 / 1024, 2) fixed_size_in_mb from sys.v_$sgastat b €where b.name = 'fixed_sga'), (select round (sum (c.bytes) / 1024 / 1024, 2) lb_size_in_mb from sys.v_$sgastat c €where c.name= 'log_buffer' ), (select round (sum (d.value) / 1024 / 1024, 2) sp_size_in_mb from sys.v_$parameter d €where d.name = 'shared_pool_size'), (select round (sum (e.value) / 1024 / 1024, 2) lp_size_in_mb from sys.v_$parameter e €where e.name = 'large_pool_size' ), (select round (sum (f.value) / 1024 / 1024, 2) jp_size_in_mb from sys.v_$parameter f €where f.name = 'java_pool_size'); €

----------

memsnap.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. Use at your own risk. To license this script for a commercial purpose, contact info@rampant.cc ************************************************* buffer_hit_ratio, percent_shared_pool_free, lib_cache_hit_ratio, object_reloads, dd_cache_hit_ratio, redo_log_space_waits, redo_log_space_wait_time, mem_sort_ratio, parse_execute_ratio, buffer_busy_waits, latch_miss_ratio

select

from (select 100 100 *

(round ((sum (decode (name, 'physical reads', value, 0)) sum (decode (name, 'physical reads direct', value, 0)) sum (decode (name, 'physical reads direct (lob)', value, 0))) / (sum (decode (name, 'session logical reads', value, 1))),3)) buffer_hit_ratio €from sys.v_$sysstat €where name in ('session logical reads', 'physical reads direct (lob)', 'physical reads', 'physical reads direct')), (select round (100 * (free_bytes / shared_pool_size), 2) percent_shared_pool_free from (select sum (bytes) free_bytes from sys.v_$sgastat where name = 'free memory' and pool = 'shared pool'), (select value shared_pool_size from sys.v_$parameter where name = 'shared_pool_size')), (select 100 - round ((sum (reloads) / sum (pins)) * 100, 2) lib_cache_hit_ratio from sys.v_$librarycache), (select 100 - round ((sum (getmisses) / (sum (gets) + sum (getmisses)) * 100), 2) dd_cache_hit_ratio from sys.v_$rowcache), (select round ( (100 * b.value) / decode ((a.value + b.value), 0, 1, (a.value + b.value)), €€€€€€2)mem_sort_ratio from v$sysstat a, v$sysstat b €where a.name = 'sorts (disk)' and b.name = 'sorts (memory)'), (select round(100 * (sum (sys.v_$latch.misses) / sum (sys.v_$latch.gets)),2) latch_miss_ratio €€from sys.v_$latch), (select round (100 * (a.value - b.value) / decode (a.value, 0, 1, a.value), 2) parse_execute_ratio from sys.v_$sysstat a, sys.v_$sysstat b

€where a.name = 'execute count' and b.name = 'parse count (hard)'), (select nvl(sum(total_waits),0) buffer_busy_waits from sys.v_$system_event a, sys.v_$event_name b where a.event = 'buffer busy waits' and a.event (+) = b.name), (select sum(reloads) object_reloads from sys.v_$librarycache), (select value redo_log_space_waits from sys.v_$sysstat where name = 'redo log space requests'), (select value redo_log_space_wait_time from sys.v_$sysstat where name = 'redo log space wait time');

----------

poolhit.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. Use at your own risk. To license this script for a commercial purpose, contact info@rampant.cc ************************************************* name, 100 * (1 - (physical_reads / (db_block_gets + consistent_gets))) hit_ratio

select

from €€€€sys.v$buffer_pool_statistics where db_block_gets + consistent_gets > 0;

-cacheadvice.sql -- ************************************************* -- Copyright © 2005 by Rampant TechPress -- This script is free for non-commercial purposes

cc ************************************************* size_for_estimate. buffers_for_estimate. ---------- cacheobjcnt. 'default'. 1.user$ where name not in ('sys'.------ with no warranties.'system')) group by decode(cachehint. 0. 2.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. To license this script for a commercial purpose. Use at your own risk. estd_physical_read_factor. 'recycle'.v_$db_cache_advice where name = 'DEFAULT'and block_size = (select value from sys. contact info@rampant.v_$parameter €€€€€€€€€€€€€€where name = 'db_block_size') and advice_status = 'ON'.seg$ s where s. contact info@rampant. 'keep'. estd_physical_reads select from sys. count(*) objects select from sys. 1. . 0. Use at your own risk. To license this script for a commercial purpose. 2. 'default'. 'keep'. null) cache. null) order by 1. 'recycle'.user# in (select user# from sys.cc ************************************************* decode(cachehint.

sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.ts$ b where state = 0 and a.ts# order by 1.x$bh a.x$bh a.ts# union all select 'read/mod' buffer_state. €€€€nvl(sum(blocksize) / 1024 . sys. -- libdet.0) amt_kb from sys.ts# = b. sys.ts# union all select 'read/notmod'.ts$ b where state = 3 and a. nvl(sum(blocksize) / 1024 .x$bh a.ts# = b.ts# = b.x$bh a. Use at your own risk. nvl(sum(blocksize) / 1024 .0) amt_kb from sys. sys.ts# = b.0) amt_kb from sys. contact info@rampant.0) amt_kb select from sys.sql . sys.cc ************************************************* 'free' buffer_state.---------- buffutl.ts# union all select 'being read' buffer_state. To license this script for a commercial purpose.ts$ b where state = 1 and €€€a. nvl(sum(blocksize) / 1024 .ts$ b where state = 2 and a.

To license this script for a commercial purpose.name.name -------- libobj. round(pinhitratio*100. . Use at your own risk.2) pinhitratio.cc ************************************************* €namespace. invalidations select from sys.v_$event_name b where a. ---------- libwait. To license this script for a commercial purpose. reloads.name and b.total_waits). 'library cache lock'. pins.0) select from sys. gets.2) gethitratio.event (+) = b. contact info@rampant.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.--------- ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. nvl(max(a.'library cache load lock'.cc ************************************************* b. Use at your own risk. contact info@rampant. Use at your own risk.'library cache pin') group by b.v_$librarycache order by 1. round(gethitratio*100.v_$system_event a. sys. To license this script for a commercial purpose.name in ('latch free'.

To license this script for a commercial purpose. gets. usage. 100 .contact info@rampant. kept from sys. €type.cc -. Use at your own risk. ---------- shared_pool.bytes)/(1024*1024) shared_pool_used. contact info@rampant. getmisses. loads.************************************************* select owner.v_$rowcache where gets + getmisses <> 0 order by 5 desc. executions. ---------- dictdet. pins.cc ************************************************* select sum(a.cc ************************************************* parameter. locks.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. contact info@rampant.2) hit_ratio select from sys.-. name. To license this script for a commercial purpose. Use at your own risk.v_$db_object_cache order by type asc. sharable_mem.round((getmisses/ (gets + getmisses) * 100). .

value))*100 shared_pool_pct from v$sgastat a. runtime_mem from sys.bytes)/(1024*1024)) shared_pool_avail.999.name != free memory and b.cc ************************************************* areas sharable persistent runtime username format format format format 999. (sum(a. contact info@rampant. persistent_mem.parsing_user_id = b. Use at your own risk.value)/(1024*1024) shared_pool_size XE "shared_pool_size" . Use at your own risk. To license this script for a commercial purpose. dba_users b where a. contact info@rampant.bytes)/max(b. sharable_mem.999 999.pool = shared pool and a. v$parameter b where a.999.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.name='shared_pool_size XE "shared_pool_size" '.cc ************************************************* create or replace view sql_summary as select username.999. ---------- sql_summary.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.max(b.value)/(1024*1024))-((sum(a.v_$sqlarea a.user_id.999 a15 heading heading heading heading heading Used Areas Shared Bytes Persistent Bytes Runtime Bytes "User" column column column column column . max(b. ---------- sqlsum. To license this script for a commercial purpose.999 999.

count(*) Areas.Copyright © 2005 by Rampant TechPress -.999 heading Mem Sum ttitle "Users SQL Area Memory Use" spool sqlsum set pages 59 lines 80 break on report compute compute compute compute sum sum sum sum of of of of sharable on report persistent on report runtime on report mem_sum on report select username.To license this script for a commercial purpose.sql -.************************************************* column sql_text format a60 heading Text word_wrapped column sharable_mem heading Shared Bytes column persistent_mem €€€€heading Persistent Bytes column loads heading Loads column users format a15 heading "User" column executions heading "Executions" column users_executing heading "Used By" ttitle "Users SQL Area Memory Use" spool sqlmem set long 2000 pages 59 lines 132 break on users compute sum of sharable_mem on users compute sum of persistent_mem on users compute sum of runtime_mem on users .cc -.with no warranties. -.************************************************* -. spool off pause Press enter to continue clear columns clear breaks set pages 22 lines 80 ttitle off -sqlmem.This script is free for non-commercial purposes -.contact info@rampant. sum(sharable_mem+persistent_mem+runtime_mem) Mem_sum from sql_summary group by username order by 2.column mem_sum format 999. --. sum(sharable_mem) Sharable. sum( runtime_mem) Runtime .999. Use at your own risk. sum( persistent_mem) Persistent.

loads. sys. SUM(c. users_executing.username.username users. to_char((b.999. To license this script for a commercial purpose.persistent_mem) Good FROM dba_users b. a.users users.999.parsing_user_id = b. TO_NUMBER(null) good FROM sys.sharable_mem+a.user_id = c. spool off pause Press enter to continue clear columns clear computes clear breaks set pages 22 lines 80 ---------- sql_garbage. sql_garbage b . dba_users b WHERE (a.'9.parsing_user_id = b.parsing_user_id and c.v_$sqlarea a.garbage))*100.999.user_id €and b.executions<=1) GROUP BY b.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. dba_users b where a.persistent_mem) Garbage.good.username like upper('%&user_name%') order by 3 desc.sharable_mem+c. persistent_mem from sys.v_$sqlarea a. to_char(b. Use at your own risk.v_$sqlarea c WHERE (b. TO_NUMBER(null) garbage.999') good_percent from sql_garbage a. to_char(a. Executions.good/(b.user_id and a.999') good. SUM(a.999.999.select username users.username UNION SELECT DISTINCT b. column garbage format a14 heading 'Non-Shared SQL' column good format a14 heading 'Shared SQL' column good_percent format a14 heading 'Percent Shared' column users format a14 heading users column nopr noprint set feedback off ttitle 'Shared Pool Utilization' spool sql_garbage select 1 nopr. contact info@rampant.good+a.'9.garbage.999.999') garbage. sql_text.username users. €sharable_mem.executions>1) GROUP BY b.cc ************************************************* REM View to sort SQL into GOOD and GARBAGE REM CREATE OR REPLACE VIEW sql_garbage AS SELECT b.'9.1.

good is not null order by 1. to_char(count(a.999.garbage).999. Use at your own risk. '--------------' good_percent from dual union select 3 nopr.&&chars Characters' col username format a15 heading 'User' ttitle 'Similar SQL' spool similar_sql&&chars select b.sql_text. contact info@rampant.sql_text) num_of_tim es from v$sqlarea a.sql_text)>&&num_ repeats order by count(a.username. '-------------' users.1.parsing_user_id=b.where a.3 desc / spool off ---------- similar_sql.users=b. sql_garbage b where a.999.substr(a.sql_text) desc / spool off undef chars undef num_repeats clear columns set lines 80 pages 22 verify on feedback on ttitle off -- Flush_it_proc.999') good.username.999.999') good_percent from sql_garbage a.good is not null union select 2 nopr. '--------------' good.'9.users and a.&&chars) SQL. '9.user_id group by b. '--------------' garbage.sql .cc ************************************************* set lines 140 pages 55 verify off feedback off col num_of_times heading 'Number Of Repeats' col SQL heading 'SubString width .good)+sum(a.sql_text.'9. To license this script for a commercial purpose.good)/(sum(b.999.&&chars) having count(a.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. to_char(((sum(b. to_char(sum(a.garbage is not null and b.999. dba_users b where a.1.users=b.good).substr(a. count(a.garbage)))*100).999') garbage.users and a.garbage is not null and b.users)) users. to_char(sum(b.

sequence_name FROM sys.--------- ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.v_$sqlarea WHERE executions > num_runs. 6. 9).SUM(a.pool='shared pool' €AND a. sequence_owner varchar2(30). 7. Use at your own risk. row_proc NUMBER. decode(kglobtyp. num_runs IN NUMBER) IS -CURSOR get_share IS SELECT LEAST(MAX(b. cur INTEGER. To license this script for a commercial purpose. 'P') FROM sys. sql_com VARCHAR2(60). .x_$kglob WHERE inst_id = userenv('Instance') AND kglnaown = 'SYS' AND kglobtyp in (6. -CURSOR cached_sequences IS SELECT sequence_owner.Following cursors from Steve Adams Nice_flush -CURSOR reused_cursors IS SELECT address '.end of Steve Adams Cursors -todays_date DATE. 8. -CURSOR get_var IS €SELECT value/(1024*1024) €FROM v$parameter €WHERE name = 'shared_pool_size'. --. 'Q'. -CURSOR get_time IS €SELECT sysdate FROM dual.name <> ('free memory')) €AND b. share_mem NUMBER.name = 'shared_pool_size'. mem_ratio NUMBER.cc ************************************************* CREATE OR REPLACE PROCEDURE flush_it( p_free IN NUMBER. object_type char(1). sequence_name varchar2(30). cursor_string varchar2(30). --.value)/(1024*1024).' hash_value FROM sys. -CURSOR candidate_objects IS SELECT kglnaobj. object_name varchar2(128). v$parameter b €WHERE (a. variable_mem NUMBER. contact info@rampant.bytes)/(1024*1024)) FROM v$sgastat a.dba_sequences WHERE cache_size > 0.

-BEGIN €OPEN get_share; €OPEN get_var; €FETCH get_share INTO share_mem; €FETCH get_var INTO variable_mem; €mem_ratio:=share_mem/variable_mem; €IF mem_ratio>p_free/100 THEN €-€-- Following keep sections from Steve Adams nice_flush €-€BEGIN OPEN reused_cursors; LOOP FETCH reused_cursors INTO cursor_string; EXIT WHEN reused_cursors%notfound; sys.dbms_shared_pool.keep(cursor_string, 'C'); END LOOP; €END; €BEGIN OPEN cached_sequences; LOOP FETCH cached_sequences INTO sequence_owner, sequence_name; EXIT WHEN cached_sequences%notfound; sys.dbms_shared_pool.keep(sequence_owner '.' sequence_name, 'Q'); END LOOP; €END; €BEGIN OPEN candidate_objects; LOOP €FETCH candidate_objects INTO object_name, object_type; EXIT WHEN candidate_objects%notfound; sys.dbms_shared_pool.keep('SYS.' object_name, object_type); END LOOP; €END; €-€-- end of Steve Adams section €-cur:=DBMS_SQL.OPEN_CURSOR; sql_com:='ALTER SYSTEM FLUSH SHARED_POOL'; DBMS_SQL.PARSE(cur,sql_com,dbms_sql.v7); row_proc:=DBMS_SQL.EXECUTE(cur); DBMS_SQL.CLOSE_CURSOR(cur); OPEN get_time; FETCH get_time INTO todays_date; INSERT INTO dba_running_stats VALUES ( 'Flush of Shared Pool',1,35,todays_date,0 ); COMMIT; €END IF; END flush_it;

--

Gen_keep.sql

-- *************************************************

--------

Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. €Use at your own risk. To license this script for a commercial purpose, contact info@rampant.cc *************************************************

set lines 132 feedback off verify off set pages 0 spool keep_them.sql select 'execute dbms_shared_pool.keep(' chr(39) OWNER '.' name chr(39) ', ' chr(39) decode(type,'PACKAGE','P','PROCEDURE','P','FUNCTION','P','SEQUENCE','Q', 'TRIGGER','R') chr(39) ')' from €v$db_object_cache where €type not in ('NOT LOADED','NON-EXISTENT','VIEW','TABLE', 'INVALID TYPE','CURSOR','PACKAGE BODY') €and executions>loads and executions>1 and kept='NO' order by owner,namespace,type,executions desc / spool off

----------

keep_them.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. Use at your own risk. To license this script for a commercial purpose, contact info@rampant.cc ************************************************* dbms_shared_pool.keep('APPS.WF_PARAMETER_T','') dbms_shared_pool.keep('APPS.WF_EVENT_T','') dbms_shared_pool.keep('APPS.WF_AGENT_T','') dbms_shared_pool.keep('APPS.BOSS_GET_EMP_NAME','P') dbms_shared_pool.keep('APPS.BEN_PEN_BUS','P') dbms_shared_pool.keep('APPS.PAY_ELE_SHD','P') dbms_shared_pool.keep('APPS.PSB_HR_POPULATE_DATA_PVT','P') dbms_shared_pool.keep('APPS.BEN_ENROLLMENT_ACTION_ITEMS','P') dbms_shared_pool.keep('APPS.FND_REQUEST_SET','P') dbms_shared_pool.keep('APPS.BOSS_RECEIPT','P') dbms_shared_pool.keep('APPS.BEN_ELIG_DPNT_WHO','R') dbms_shared_pool.keep('APPS.BEN_ELIG_PER_ELCTBL_CHC_WHO','R') dbms_shared_pool.keep('APPS.BEN_ELIG_PER_OPT_F_WHO','R') dbms_shared_pool.keep('APPS.GHR_PAY_ELEMENT_ENTVAL_F_AFIUD','R') dbms_shared_pool.keep('APPS.BEN_ENRT_RT_WHO','R') dbms_shared_pool.keep('APPS.BEN_ELIG_PER_F_WHO','R')

execute execute execute execute execute execute execute execute execute execute execute execute execute execute execute execute

----------

ddcache.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. Use at your own risk. To license this script for a commercial purpose, contact info@rampant.cc *************************************************

ttitle "DD Cache Hit Ratio" spool ddcache SELECT (SUM(getmisses)/SUM(gets))*100 RATIO FROM v$rowcache; spool off pause Press enter to continue ttitle off

----------

bufobjwaits.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. Use at your own risk. To license this script for a commercial purpose, contact info@rampant.cc ************************************************* owner, object_name, object_type, value waits

select

from sys.v_$segment_statistics where (statistic_name = 'buffer busy waits' and value > 0) order by 1,2;

-------

libcachhist.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. Use at your own risk.

gets . e.namespace "Name Space" . To license this script for a commercial purpose.pins . value.gets "Get Requests" . 'YYYY-MON-DD HH:MI:SS') end_time.pinhits) * 100/(e.b. e. e. .b. to_number(decode(e.gethits . dba_hist_librarycache e €where b. Use at your own risk.instance_number = e.gets.(e.************************************************* select to_char(end_time.namespace ----- rowcache_int_10g.instance_number = &pInstNum and b.pins. Use at your own risk.null.(e.pins.gets. contact info@rampant.pinhits .sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. metric_unit from sys.instance_number and b.b.b. -.invalidations .b.-.pins))) "Pin Pct Miss" .b.b.pins "Pin Requests" .instance_number = &pInstNum and e.dbid and b.v_$sysmetric_history where metric_name = 'Library Cache Hit Ratio' order by 1 ---------- lib_cache_int_10g.gets))) "Get Pct Miss" .cc ************************************************* select b.gets . e.reloads .b.b.snap_id = &pEndSnap and b.dbid = &pDbId and e.gethits) * 100/(e.snap_id = &pBgnSnap and e.dbid = e.contact info@rampant.reloads "Reloads" .b. 100 .dbid = &pDbId and b.pins .To license this script for a commercial purpose.null.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.namespace = e. 100 . to_number(decode(e.cc -.invalidations "Invalidations" from dba_hist_librarycache b .

--.snap_id = &pBgnSnap and e.b.b.gets > 0 ) €order by param.b.gets gets .gets.b. To license this script for a commercial purpose.scanmisses . phwrite "Physical Writes" . to_number(decode(e. contact info@rampant. ---------- Buf_pool_int_10g.b. fbwait "Free Buffer Waits" .getmisses .dbid = &pDbId and e. scans "Scan Requests". (e.To license this script for a commercial purpose.null. getm "Pct Miss".gets. numbufs "Number of Buffers" .b.cc -. scanm "Pct Miss".b.b.gets . mods "Mod Req". usage "Final Usage" From (select lower(b.b.snap_id = &pEndSnap and b.scans))) scanm .cc ************************************************* select name .instance_number = &pInstNum and e.modifications . gets "Get Requests".scans.gets .dbid and b.dbid = e.scans scans . conget "Consistent Gets" .instance_number = &pInstNum and b.scans .dbid = &pDbId and b.scanmisses) * 100/(e. (e.gets .instance_number = e. e.parameter = e.usage usage from dba_hist_rowcache_summary b .b.getmisses) * 100/(e. to_number(decode(e.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.scans . bbwait "Buffer Busy Waits" .parameter) param . Use at your own risk. phread "Physical Reads" . e. e.gets))) €€getm .scans.************************************************* select param "Parameter".modifications €€€€mods .instance_number and b. e. buffs "Buffer Gets" .parameter and e.null. -. dba_hist_rowcache_summary e €where b.contact info@rampant.

dbid and b.0) phwrite .snap_id = &pEndSnap and b.set_msize €numbufs .consistent_gets.nvl(b. wcwait "Write Complete Waits" . 0.0) .0) fbwait .0) + e.999.buffer_busy_wait.id) €order by 1 ---------- rpt_10g_lib_miss.nvl(b. e.0) + e.999. .consistent_gets. set pages 999.99999 break on mydate skip 2.physical_reads.db_block_gets.physical_reads.cc ************************************************* set lines 80.0) buffs .instance_number(+) = &pInst_Num and e.. (100* (1 .nvl(b. e.physical_writes . column column column column mydate heading 'Yr.db_block_gets .0) bbwait from dba_hist_buffer_pool_stat b .instance_number = &pInst_Num and b.999 c2 heading "Cache Misses While Executing" format 9. contact info@rampant.nvl(b.free_buffer_wait .instance_number(+) = e.physical_writes. e.physical_reads .0)) €€€€€€€€€€€€€€€/ ( e.dbid(+) = e.nvl(b.id(+) = e.0) phread .dbid €€€€€€€€€€€= &pDbId and b.consistent_gets .( (e.consistent_gets.nvl(b.write_complete_wait .nvl(b. e. dba_hist_buffer_pool_stat e €where b.db_block_gets.0) conget .0) + e.db_block_gets.write_complete_wait.instance_number and b. to_number(null) . To license this script for a commercial purpose. e.nvl(b. Use at your own risk. e.nvl(b.nvl(b.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.physical_reads .buffer_busy_wait .db_block_gets .name .consistent_gets.dbid(+) = &pDbId and e.999 c3 heading "Library Cache Miss Ratio" format 999.consistent_gets .nvl(b. decode( e. poolhr "Pool Hit %" From (select e.0)) ) ) ) ) €€€€€€€€€€€€€€€€€€€poolhr .nvl(b. Mo Dy Hr.db_block_gets .' format a16 c1 heading "execs" format 9.consistent_gets .snap_id(+) = &pBgnSnap and e. e.consistent_gets . e.nvl(b.0) wcwait .free_buffer_wait.

snap_id = sn.'yyyy-mm-dd HH24') . ---------- rpt_bhr_awr_hr.end_interval_time.pins-old. dba_hist_sga sn where new.reloads-old. dba_hist_snapshot sn where new.physical_reads)) / ((new.name = old. contact info@rampant.snap_id .'yyyy-mm-dd HH24') mydate.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. avg( (((new. column bhr format 9. sum(new.snap_id = sn.snap_id and old. To license this script for a commercial purpose.db_block_gets-old. dba_hist_buffer_pool_stat new.pins) library_cache_miss_ratio from dba_hist_librarycache old. dba_hist_librarycache new. Use at your own risk.namespace group by to_char(sn.name in ('DEFAULT'.reloads-old.snap_id-1 and old. mo dy Hr.db_block_gets)) ) bhr from dba_hist_buffer_pool_stat old.snap_id = new.' select to_char(snap_time. sum(new.db_block_gets-old.99 column mydate heading 'yr.'HH24') mydate.consistent_gets)+ (new.consistent_gets)+ (new.pins) c1.consistent_gets-old.pins-old.cc ************************************************* set pages 999.reloads) €c2.namespace = new.physical_reads-old.'FAKE VIEW') and new.db_block_gets))(new.consistent_gets-old.end_interval_time.select to_char(sn. sum(new.reloads)/ sum(new.name and new.

consistent_gets-old. dba_hist_snapshot sn where new.99 column mydate heading 'yr.name in ('DEFAULT'.consistent_gets-old.consistent_gets > 0 having avg( (((new.consistent_gets > 0 and old.consistent_gets)+ (new.name = old. To license this script for a commercial purpose.name and new.'day') mydate.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. avg( (((new.consistent_gets)+ (new.physical_reads)) / ((new.db_block_gets-old.physical_reads-old.snap_id = sn.'FAKE VIEW') and new.and old.' select to_char(end_interval_time.db_block_gets)) ) bhr from dba_hist_buffer_pool_stat old.db_block_gets-old.snap_id = sn. dba_hist_buffer_pool_stat new. Use at your own risk.db_block_gets)) ) < 1 group by to_char(snap_time. contact info@rampant.db_block_gets))(new.snap_id and .physical_reads-old.db_block_gets-old.cc ************************************************* set pages 999. --------- rpt_bhr_awr_dy.physical_reads)) / ((new.db_block_gets-old.snap_id-1 and new.db_block_gets))(new. mo dy Hr.consistent_gets-old.'HH24') . column bhr format 9.consistent_gets)+ (new.consistent_gets)+ (new.consistent_gets-old.

consistent_gets)+ (new.table_name = p.consistent_gets-old.table_name = s.'day') .db_block_gets-old.segment_name and t.'SYSTEM') .' from dba_tables t.owner = p.sql_id = p.object_name name from dba_hist_sql_plan pl where pl. ---------- get_keep_pool_awr.physical_reads-old.owner and t.owner not in ('SYS'.snap_id = sn.' p.owner '.consistent_gets)+ (new. (select distinct pl.db_block_gets-old.owner and t.name and t.db_block_gets)) ) < 1 group by to_char(end_interval_time.options = 'FULL') p where a.cc ************************************************* select 'alter table ' p.object_owner owner.old.consistent_gets-old. pl.physical_reads)) / ((new.snap_id-1 and new.owner = s. Use at your own risk.consistent_gets > 0 having avg( (((new.operation = 'TABLE ACCESS' and pl. To license this script for a commercial purpose. contact info@rampant.sql_id.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. dba_hist_sqlstat a.name ' storage (buffer_pool keep). pl.db_block_gets))(new.sql_id and t.consistent_gets > 0 and old. dba_segments s.

name from dba_tables t.*********************************************************** select 'alter index ' owner '. get the index names -.buffer_pool <> 'KEEP' having s.*********************************************************** -.blocks < 50 group by p.object_name name from dba_hist_sql_plan pl where pl.sql_id and t.Next. (select distinct pl. s.object_owner owner.' p.owner not in ('SYS'.owner and t.name.blocks < 50 group by p.owner.options = 'FULL') p where a.blocks ) .buffer_pool <> 'KEEP' having s.segment_name and t. dba_segments s.sql_id = p.blocks UNION -.owner and t.owner '.' table_name in ( select p. t.num_rows. p.table_name = p. p. t.owner = p. s.num_rows.owner = s.owner.'SYSTEM') and t.and t.' index_name ' storage (buffer_pool keep).name. pl. pl. dba_hist_sqlstat€€a.sql_id.' from dba_indexes where owner '.name and t.operation = 'TABLE ACCESS' and pl.table_name = s.

p.name) username.v_$session b. total_user_scans. sys.p.v_$sesstat a where a.paddr and b.sid sid.sid and c.username. (select €sum(value) total_scans from sys. Use at your own risk.statistic#=c.sid=a.Copyright © 2005 by Rampant TechPress -. contact info@rampant.statistic# and p.name = 'table scans (long tables)' group by b.sql -. round(100 * total_user_scans/total_scans. nvl(b.statistic# and c.statistic#=c.************************************************* select .cc ************************************************* sid.sid. --. sys.This script is free for non-commercial purposes -.v_$statname c.username.---------- userscans.v_$statname c.v_$bgprocess p where a.To license this script for a commercial purpose.with no warranties. sys.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.************************************************* -.name = 'table scans (long tables)'). Use at your own risk.v_$sesstat a. -scatwait.2) pct_scans select from (select b. username. sum(value) total_user_scans from sys.name) order by 3 desc). nvl(b. -. €€sys. To license this script for a commercial purpose.contact info@rampant.cc -.paddr (+) = b.

2) max_wait_sec from sys. ---------- 9ilarge_scanusers.username order by 2 desc.segment_type in ('TABLE'.username username. Use at your own risk.2) average_wait_sec.max_wait / 100).sid and c. .object_owner (+) = b.options = 'FULL' and c.paddr (+) = b.name) username.sid.object_name (+) = b.c. sys. To license this script for a commercial purpose. count(a.bytes / 1024 > 1024 group by c. round((average_wait / 100).v_$session b. b. round((a.paddr order by 3 desc. a.segment_name and b.total_waits. 'TABLE PARTITIOn') and a.sid = b.parsing_user_id and d. nvl(b.dba_users c.v_$sql d where a.dba_segments b.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. sys.a.b.hash_value) scan_count select from sys. sys.owner and a.cc ************************************************* c.operation like '%TABLE%' and a. sys.username. contact info@rampant. round((a. €1 asc.time_waited / 100).user_id = d. sys.v_$session_event a.v_$sql_plan a.total_timeouts.machine.hash_value = a.hash_value and b.2) time_wait_sec.v_$bgprocess c €where event = 'db file scattered read' and a.

sql_address = a.name) order by 3 desc) where rownum < 2) order by a. Use at your own risk.cc ************************************************* sid. nvl(b.sid = (select sid from (select b. sys. To license this script for a commercial purpose. nvl(b.p. sys. 'physical writes direct (lob)') group by b. sys.'physical writes'.sid sid.v_$session b.username. sql_text select from sys. 'physical reads direct'. sys.piece. -- cartsession.---------- curriosql.p.v_$session b where b.v_$sesstat a. sum(value) total_user_io from sys.sid and c.sid.statistic# and p.v_$bgprocess p where a.v_$sqltext a.sid=a. username.statistic#=c. 'physical reads direct (lob)'.sql .name in ('physical reads'.username.paddr and b.address and b.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.name) username. 'physical writes direct'. contact info@rampant.paddr (+) = b.v_$statname c.

---------- cartsql.v_$sql_plan where options = 'CARTESIAN' and operation LIKE '%JOIN%' ) order by hash_value. Use at your own risk. Use at your own risk.dba_users b.v_$sql where hash_value in (select hash_value from sys.parsing_user_id = b.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. count(distinct c.hash_value) nbr_stmts select from sys.v_$sql_plan c where a.v_$sql a.hash_value group by username order by 2 desc.hash_value = c. contact info@rampant. sys. contact info@rampant.cc ************************************************* * select from sys.--------- ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. To license this script for a commercial purpose. To license this script for a commercial purpose.user_id and options = 'cartesian' and operation like '%join%' and a. €€sys.cc ************************************************* username. .

elapsed_time_secs_per_execute.buffer_gets. a.3) cpu_time_secs. executions . b. hit_ratio.round(100 * a.executions)).0. a.1.loads. a. runtime_mem.cc ************************************************* sql_text . address.executions.0. parse_calls .2) hit_ratio.disk_reads/ greatest(a. first_load_time . round((a.1. buffer_gets_per_exec. buffer_gets . 100 . round(cpu_time / 1000000. rows_processed .buffer_gets . cpu_time_secs_per_execute.executions. persistent_mem . To license this script for a commercial purpose. sorts . contact info@rampant. hash_value select from (select sql_text .a.first_load_time .parse_calls . a.executions)).---------- top9isql.3) .a. round((cpu_time / 1000000)/ decode(a.sorts . sharable_mem .1).rows_processed . disk_reads.0. a. runtime_mem.executions).executions .disk_reads/ decode(a.2) buffer_gets_per_exec.executions. Use at your own risk.1. persistent_mem .a. username .disk_reads . sharable_mem . a. cpu_time_secs. a. round((a.2) disk_reads_per_exec. loads. elapsed_time_secs.buffer_gets/ decode(a.username . a.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. disk_reads_per_exec.

hash_value from sys. contact info@rampant.1. To license this script for a commercial purpose.username not in ('SYS'.parsing_user_id=b. ---------- 9icartcount. round((elapsed_time / €€€1000000)/decode(a.cc ************************************************* select sql_text from sys.3) elapsed_time_secs_per_execute.v_$sqlarea a.3) elapsed_time_secs. address.executions. sys.all_users b where a.executions).sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.0. round(elapsed_time / 1000000.a.v_$sqltext where hash_value = <enter hash value for sql statement> order by piece. ---------- fullsql. count(*) total_cartesian_joins select .sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.cc ************************************************* count(distinct hash_value) cartesian_statements.'SYSTEM') order by 3 desc) where rownum < 21.cpu_time_secs_per_execute. Use at your own risk. Use at your own risk. To license this script for a commercial purpose.user_id and b. contact info@rampant.

To license this script for a commercial purpose. To license this script for a commercial purpose. total_large_scans.cc ************************************************* * select from sys.v_$sql_plan where options = 'CARTESIAN' and operation like '%JOIN%'. . executions * total_large_scans sum_large_scans select from (select sql_text.v_$sql_plan €where options = 'CARTESIAN' €AND operation LIKE '%JOIN%' ) order by hash_value. executions. ---------- 9icartsql.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. contact info@rampant.cc ************************************************* sql_text. ---------- 9itabscan. Use at your own risk. Use at your own risk.from sys.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. contact info@rampant.v_$sql where hash_value in (select hash_value €from €€sys.

hash_value = b. object_name.id = b. sys.hash_value and a.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. executions from sys.options = 'FULL' c.hash_value = <enter hash value> order by a. and and and and and and group ---------- 9iplanstats.segment_type in ('TABLE'. . sys. Use at your own risk. executions) order by 4 desc.object_owner (+) = b.segment_name b.operation like '%TABLE%' a. options.v_$sql c where a.count(*) total_large_scans. To license this script for a commercial purpose. sys. last_disk_writes.id. object_owner. last_output_rows.dba_segments b.owner a. 'TABLE PARTITION') a.hash_value = a. contact info@rampant.v_$sql_plan_statistics b where a.v_$sql_plan a.cc ************************************************* operation.object_name (+) = b.bytes / 1024 > 1024 by sql_text. last_cu_buffer_gets.v_$sql_plan a. last_cr_buffer_gets. last_elapsed_time select from sys. executions.hash_value b.operation_id and a. last_disk_reads.

999. column ct heading "# of SQL selects" format 999. set heading on. (select distinct .lst. --spool access. v$sqlarea a. dba_segments s. t.'N') K. a1. set heading off.999 a14.num_rows. select object_owner. sum(a.executions) nbr_FTS from dba_tables t. count(*) ct from v$sql_plan where object_owner is not null group by object_owner order by ct desc .'Y'.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. -.'DEFAULT'. set feedback on set pages 999. decode(t. p.owner. s.ltrim(t.name.buffer_pool. Use at your own risk. contact info@rampant. ttitle 'full table scans and counts The "K" indicates that the table is in th e KEEP Pool (Oracle8). set feedback on. column object_owner heading "Owner" format a12.'KEEP'.999 999.cc ************************************************* set echo off.999. column nbr_FTS column num_rows column blocks column owner column name column ch format format format format format format 999. To license this script for a commercial purpose. a24.blocks blocks.---------- plan9i. set feedback off.cache) ch.999 999.' select p.

owner and t.999 a15.num_rows.segment_name and t. sum(s.address and t. s. t. object_name name from v$sql_plan where operation = 'TABLE ACCESS' and options = 'BY ROWID') p where s. (select distinct address. v$sqlarea s.owner = p.owner and t. p. p. object_owner owner.executions) > 9 group by p.address and t.999 999. ttitle 'Table access by ROWID and counts' select p. t.table_name = p.table_name = p.owner not in ('SYS'. column column column column nbr_RID num_rows owner name format format format format 999.address. object_owner owner. t. t.name.executions) nbr_RID from dba_tables t.address = p.name and t. a25.999.executions) desc.cache.owner = s.name and t.999.table_name = s.name.'SYSTEM') having sum(a.owner.address = p.blocks order by sum(a.owner = p.owner having sum(s.executions) > 9 .num_rows.buffer_pool. object_name name from v$sql_plan where operation = 'TABLE ACCESS' and options = 'FULL') p where a.owner.

num_rows order by sum(s.segment_name and seg.index_name = p.table_name = seg.owner. dba_indexes d.owner having sum(s. seg.owner = p.address = p.999 999. ttitle 'Index full scans and counts' select p.blocks order by sum(s.group by p. sum(s. --************************************************* -. d.name and s.name. p.table_name. a20.name index_name.executions) desc. p.address and d. (select distinct address. p. v$sqlarea s.999. a20.owner.executions) nbr_scans from dba_segments seg.executions) desc. t. d.owner.executions) > 9 group by p. sum(s.executions) nbr_scans .999.blocks tbl_blocks. seg.blocks tbl_blocks. object_name name from v$sql_plan where operation = 'INDEX' and options = 'FULL SCAN') p where d.name.999 999.Index Report Section --************************************************* column column column column column column nbr_scans num_rows tbl_blocks owner table_name index_name format format format format format format 999.owner. d.999 a9.table_name. ttitle 'Index range scans and counts' select p. object_owner owner.table_name. p.name index_name. seg.999.

owner having sum(s.executions) > 9 group by p.name order by sum(s. dba_indexes d.blocks order by sum(s.name and s.executions) nbr_scans from v$sqlarea s. sum(s. object_owner owner. seg.segment_name and seg.name.executions) desc.name index_name.owner.executions) > 9 group by p.index_name = p. .address = p.owner = p.owner.address = p.owner.address and d.address having sum(s. d.table_name. d. object_name name from v$sql_plan where operation = 'INDEX' and options = 'UNIQUE SCAN') p where d. (select distinct address. p.table_name. p.from dba_segments seg.index_name = p. ttitle 'Index unique scans and counts' select p.name and s. object_name name from v$sql_plan where operation = 'INDEX' and options = 'RANGE SCAN') p where d.table_name = seg. v$sqlarea s. p.executions) desc.table_name. object_owner owner. dba_indexes d. (select distinct address. d.

v_$sql_plan connect by prior id = parent_id and prior hash_value = hash_value start with €€€€€id = 0 and hash_value = <enter hash value> order by id.---------- 9iexpl.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.cc ************************************************* select table_owner. cardinality. table_type. select ---------- 9iltabscan. statement_count. Use at your own risk. io_cost. executions.object_owner table_owner.level-1) operation ' ' options ' ' object_name "Plan". contact info@rampant. Use at your own risk. table_name. bytes. contact info@rampant. To license this script for a commercial purpose. size_kb. executions * reference_count total_scans from (select a. To license this script for a commercial purpose. . cost. reference_count.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. cpu_cost from sys.cc ************************************************* lpad(' '.

contact info@rampant. .object_owner (+) = b. Use at your own risk.v_$sql_plan a. b.object_owner.dba_indexes d where a.object_name. 'TABLE PARTITION') and a.owner = d.object_owner table_owner.bytes / 1024 > 1024 and b.owner and a. To license this script for a commercial purpose. count( * ) reference_count from sys.bytes / 1024 > 1024 group by a.hash_value and b.dba_segments b. sys.object_name table_name. count( distinct a.hash_value = c. b.table_owner order by 1. d.object_name (+) = b.cc ************************************************* select distinct a.operation.options = 'FULL' and a.segment_name and b.v_$sql_plan a.bytes / 1024. b. a. sys.bytes / 1024 size_kb.hash_value ) statement_count. 2.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.object_owner (+) = b. b.executions ) executions. ---------- 9iunused_indx.owner and a.bytes / 1024 size_kb.object_name (+) = b.operation like '%TABLE%' and a. 2 ).options = 'FULL' and b.segment_name and b.operation like '%TABLE%' and a.object_name table_name. b.segment_name = d.dba_segments b. 1. sum(c. a. b.a. a.segment_type table_type. sys.segment_type table_type.table_name and b. 'TABLE PARTITION') and a. sys.segment_type in ('TABLE'.segment_type in ('TABLE'.v_$sql c where a.segment_type order by 4 desc.index_name from sys.

executions_total "Executions" .0) €€from dba_hist_sysstat b1 .buffer_gets_total.dbid(+) = b. dba_hist_sqltext t where b.0))/ ( select e1.value .0)) > 0 and t.dbid(+) = e.buffer_gets_total .0) executions_total .instance_number = &pInstNum and (e.************************************************* -.stat_name = 'session logical reads' ) pct . cpu_time_total/1000000 "CPU Time (s)" .sql_id and e. (e.sql_id(+) = e.nvl(b. --.0) elapsed_time_ total . module "SQL Module" .elapsed_time_total .sql_id sql_id .nvl(b.snap_id and b1.dbid and b.0) buffer_gets_tot al .nvl(b1.snap_id(+) = b. e.dbid and b1.elapsed_time_total.nvl(b. Use at your own risk.executions_total. e. elapsed_time_total/1000000 "Elapsed Time (s)" .This script is free for non-commercial purposes -.value.instance_number and e1.executions_total .executions_total .stat_id = e1.buffer_gets_total .cc -.sql_text stmt from dba_hist_sqlstat e .instance_number = e. e.contact info@rampant.cpu_time_total . buffer_gets_total/executions_total "Gets / Exec" . pct*100 "% Total" .snap_id and e1. e.snap_id = &pEndSnap and e.To license this script for a commercial purpose.instance_number and b1.stat_id and e1.0) cpu_time_total €€€€€€.************************************************* select sql_id . buffer_gets_total "Buffer Gets" .nvl(b.module . dba_hist_sqlstat b .dbid €€€€€€€€€€€and e1.sql €-.instance_number(+) = e.buffer_gets_total.snap_id = e.cpu_time_total.dbid = &pDBId and e. e. -.nvl(b.sql_id = b.executions_total.snap_id(+) = @pBgnSnap and b.Copyright © 2005 by Rampant TechPress -. stmt "SQL Statement" from (select e.instance_number(+) = b.instance_number and b.-high_sql_buf_gets.with no warranties.dbid = e.nvl(b. t. dba_hist_sysstat e1 where b1.sql_id ) .

order by 2 desc

----------

top_sql_waits.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. Use at your own risk. To license this script for a commercial purpose, contact info@rampant.cc *************************************************

select ash.user_id, u.username, sqla.sql_text, sum(ash.wait_time + ash.time_waited) wait_time from v$active_session_history ash, v$sqlarea sqla, dba_users u where ash.sample_time > sysdate-1 and ash.sql_id = sqla.sql_id and ash.user_id = u.user_id group by ash.user_id, sqla.sql_text, u.username order by 4;

----------

obj_wait_ash.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. Use at your own risk. To license this script for a commercial purpose, contact info@rampant.cc *************************************************

select obj.object_name, obj.object_type, ash.event, sum(ash.wait_time + ash.time_waited) wait_time from v$active_session_history ash,

dba_objects obj where ash.sample_time > sysdate -1 and ash.current_obj# = obj.object_id group by obj.object_name, obj.object_type, ash.event order by 4 desc; €

----------

awr_high_scan_sql.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. Use at your own risk. To license this script for a commercial purpose, contact info@rampant.cc *************************************************

select c.username username, count(a.hash_value) scan_count from sys.v_$sql_plan a, sys.dba_segments b, sys.dba_users c, sys.v_$sql d where a.object_owner (+) = b.owner and a.object_name (+) = b.segment_name and b.segment_type IN ('TABLE', 'TABLE PARTITION') and a.operation like '%TABLE%' and a.options = 'FULL' and c.user_id = d.parsing_user_id and d.hash_value = a.hash_value and b.bytes / 1024 > 1024 group by c.username order by 2 desc ;

----------

awr_high_resource_sql.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. Use at your own risk. To license this script for a commercial purpose, contact info@rampant.cc *************************************************

select sql_text, username, disk_reads_per_exec, buffer_gets, disk_reads, parse_calls, sorts, executions, rows_processed, hit_ratio, first_load_time, sharable_mem, persistent_mem, runtime_mem, cpu_time, elapsed_time, address, hash_value from (select sql_text , b.username , €round((a.disk_reads/decode(a.executions,0,1, €a.executions)),2) disk_reads_per_exec, a.disk_reads , a.buffer_gets , a.parse_calls , a.sorts , a.executions , a.rows_processed , 100 - round(100 * a.disk_reads/greatest(a.buffer_gets,1),2) hit_ratio, a.first_load_time , sharable_mem , persistent_mem , runtime_mem, cpu_time, elapsed_time, €address, hash_value from sys.v_$sqlarea a, sys.all_users b where a.parsing_user_id=b.user_id and b.username not in ('sys','system') order by 3 desc)

contact info@rampant.v_$sql_plan where options = 'CARTESIAN' and operation LIKE '%JOIN%' ) order by hash_value.v_$sql where hash_value in (select hash_value from sys.where rownum < 21 ---------- awr_cartesian_sum. Use at your own risk.cc ************************************************* select * from sys.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.v_$sql_plan where options = 'CARTESIAN' and operation like '%JOIN%' ---------- awr_sql_cartesian.cc ************************************************* select count(distinct hash_value) carteisan_statements.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. contact info@rampant. count(*) total_cartesian_joins from sys. To license this script for a commercial purpose. To license this script for a commercial purpose. Use at your own risk. .

count(*) total_large_scans. Use at your own risk. executions * total_large_scans sum_large_scans from (select sql_text.options = 'FULL' and c.v_$sql_plan a. To license this script for a commercial purpose.operation LIKE '%TABLE%' and a. To license this script for a commercial purpose. -------- awr_sqlstat_deltas.object_owner (+) = b. 'TABLE PARTITION') and a. executions €from sys.v_$sql c €where a. executions. contact info@rampant. sys.---------- awr_large_scan_count.segment_type IN ('TABLE'.hash_value and b.dba_segments b.object_name (+) = b. Use at your own risk.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. total_large_scans. sys. .cc ************************************************* select sql_text.bytes / 1024 > 1024 group by sql_text.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. executions) order by 4 desc .hash_value = a.owner and a.segment_name and b.

disk_reads_delta c5.contact info@rampant.sql_id c2. sql.************************************************* col col col col col col col col c1 c2 c3 c4 c5 c6 c7 c8 heading heading heading heading heading heading heading heading Begin Interval time SQL ID Exec Delta Buffer Gets Delta Disk Reads Delta IO Wait Delta Application Wait Delta Concurrency Wait Delta format format format format format format format format a8 a13 9. sql.999 9.999 9. c2 .executions_delta c3.999 9.iowait_delta c6.999 9. dba_hist_snapshot s where s.cc -.ccwait_delta c8 from dba_hist_sqlstat sql.999 9.buffer_gets_delta c4.999 999. contact info@rampant.999 9.begin_interval_time.cc ************************************************* c1 c2 c3 c4 c5 c6 c7 c8 c9 heading heading heading heading heading heading heading heading heading Begin Interval time Exec Delta Buffer Gets Delta Disk Reads Delta IO Wait Delta App Wait Delta Cncr Wait Delta CPU Time Delta Elpsd Time Delta format format format format format format format format format a8 999.999 break on c1 select to_char(s. ---------- awr_sqlstat_deltas_detail. sql.999 999.999 9. sql.snap_id = sql. sql.snap_id order by c1.999 999. Use at your own risk. sql.-. To license this script for a commercial purpose.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. sql.apwait_delta c7.999 col col col col col col col col col accept sqlid prompt Enter SQL ID: . mm-dd hh24 ) c1.999 9.999 9.

snap_id = sql.sql_id and p.ccwait_delta c7.sql_text) c3 from dba_hist_sql_plan p. mm-dd hh24 ) c1. Use at your own risk. sql.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.sql_id = s. to_char(s.ttitle time series execution for &sqlid break on c1 select to_char(s. contact info@rampant.buffer_gets_delta c3.cost c2.id = 0 and p.cpu_time_delta c8.disk_reads_delta c4. dba_hist_snapshot s where €s. sql. p.elapsed_time_delta c9 from dba_hist_sqlstat sql.999 format a200 col c1 heading SQL ID col c2 heading Cost col c3 heading SQL Text select p. sql.executions_delta c2. sql. sql.iowait_delta c5. To license this script for a commercial purpose. sql. sql. dba_hist_sqltext s where p.begin_interval_time.sql_id c1. ---------- awr_high_cost_sql.999.snap_id and sql_id = &sqlid order by c1 .cost is not null .cc ************************************************* format a13 format 9. sql.apwait_delta c6.

cc ************************************************* Please enter SQL ID: format format format format format a20 a20 a25 999. ---------- awr_sql_details. Use at your own risk.cost desc .sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. contact info@rampant. search_columns c4.999 accept sqlid prompt col col col col col c1 c2 c3 c4 c5 heading heading heading heading heading Operation Options Object Name Search Columns Cardinality select operation c1. ---------- awr_hash_join_alert. options c2. Use at your own risk.999. To license this script for a commercial purpose.order by p. cardinality c5 from dba_hist_sql_plan p where p.999.cc ************************************************* format a20 format 99.sql_id = '&sqlid' order by p. object_name c3.id.999 999.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. contact info@rampant.999 col c1 heading Date col c2 heading Hash Join Count col c3 heading Rows Processed .999 format 99. To license this script for a commercial purpose.

999. column nbr_FTS column num_rows column blocks column owner column name column ch column time format 99. format a30. ---------- plan10g. format a1.cc ************************************************* spool plan.999 format a10. dba_hist_sqlstat st where st.rows_processed_delta) €€€€€€€€€€€€€€€€€€€c3. heading "Snapshot Time" format a15 format a12. dba_hist_sql_plan p.999 format 99. To license this script for a commercial purpose.begin_interval_time.999.snap_id and p. sum(st.999 format 999.col c4 heading col c5 heading Disk Reads CPU Time format 99. column object_owner heading "Owner" .cpu_time_delta) c5 from dba_hist_snapshot sn. sum(st.999 format 9. count(*) c2.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.999 accept hash_thr char prompt ttitle Enter Hash Join Threshold: Hash Join Threshold &hash_thr select to_char(sn. Use at your own risk.operation = 'HASH JOIN' having count(*) > &hash_thr group by begin_interval_time.'yy-mm-dd hh24') c1.snap_id = st.sql_id and sn. sum(st. contact info@rampant.lst set echo off set feedback on set pages 999.disk_reads_delta) c4.sql_id = p.

decode(t.'DEFAULT'.sql_id and t.sql_id = p. (select distinct pl. t.' select to_char(sn.blocks blocks. object_owner owner.'KEEP'. select object_owner. dba_hist_snapshot sn. set heading on. p.executions_delta) nbr_FTS from dba_tables t. --spool access.table_name = p. object_name name from dba_hist_sql_plan pl where operation = 'TABLE ACCESS' and options = 'FULL') p where a.segment_name and t.column ct break on time heading "# of SQL selects" format 999. ttitle 'full table scans and counts The "K" indicates that the table is in th e KEEP Pool (Oracle8).owner.'Y'.ltrim(t.buffer_pool.owner = s.name. set feedback on. sum(a. p.snap_id and a.num_rows. dba_hist_sqlstat a.999. dba_segments s.lst. s.table_name = s.end_interval_time.sql_id. -.cache) ch.'mm/dd/rr hh24') time. count(*) ct from dba_hist_sql_plan where object_owner is not null group by object_owner order by ct desc .'N') K.owner and t.name and .snap_id = sn.

end_interval_time.sql_id.'mm/dd/rr hh24').buffer_pool. p. p.executions_delta) > 9 group by to_char(sn. t.end_interval_time.owner and t.999 .owner having sum(a.999.owner = p. t. (select distinct €€pl. cache.executions_delta) > 1 group by to_char(sn. column column column column nbr_RID num_rows owner name format format format format 999.owner.999 999. object_owner owner. s.999. a25.t.owner.name.999 column tbl_blocks format 999.blocks order by 1 asc.'mm/dd/rr hh24').owner = p.end_interval_time.table_name = p. ttitle 'Table access by ROWID and counts' select to_char(sn. --************************************************* -.999.'mm/dd/rr hh24') time. dba_hist_sqlstat a. dba_hist_snapshot sn.sql_id and t.num_rows order by 1 asc.'SYSTEM') having sum(a.snap_id = sn. p.owner.p. p.num_rows. sum(a.999 a15. t.999.executions_delta) nbr_RID from dba_tables t. t.p.owner not in ('SYS'. t. object_name name from dba_hist_sql_plan pl where operation = 'TABLE ACCESS' and options = 'BY USER ROWID') p where a.name.sql_id = p.999.num_rows.999 column num_rows format 999.snap_id and a.Index Report Section --************************************************* column nbr_scans format 999.name and t.name.

object_owner owner.name index_name.owner.table_name = seg.index_name = p.'mm/dd/rr hh24'). d.sql_id and d.column owner format a9.snap_id = sn. p. column index_name format a20.blocks order by 1 asc.executions_delta) nbr_scans from dba_segments seg.'mm/dd/rr hh24') time. sum(s. dba_hist_sqlstat s. dba_indexes d.table_name.owner having sum(s.owner = p.sql_id. p. ttitle 'Index full scans and counts' select to_char(sn. p.table_name.sql_id = p. (select distinct pl.'mm/dd/rr hh24') time.end_interval_time.end_interval_time.blocks tbl_blocks.blocks tbl_blocks.name.name index_name. d. dba_hist_sqlstat s. object_name name from dba_hist_sql_plan pl where operation = 'INDEX' and options = 'FULL SCAN') p where d.owner. p.snap_id and s.end_interval_time. seg.executions_delta) > 9 group by to_char(sn.table_name. sum(s. dba_hist_snapshot sn. column table_name format a20.p. dba_hist_snapshot sn.segment_name and seg. seg.executions_delta) nbr_scans from dba_segments seg. p. seg. dba_indexes d.name and s. d.owner. ttitle 'Index range scans and counts' select to_char(sn. (select distinct .

p.'mm/dd/rr hh24') time.end_interval_time.snap_id and s.end_interval_time.name index_name.'mm/dd/rr hh24').end_interval_time.sql_id. (select distinct pl.table_name = seg.executions_delta) > 9 group by to_char(sn. d. ttitle 'Index unique scans and counts' select to_char(sn.owner = p. sum(s. object_owner owner.index_name = p.name and s.name order by 1 asc.sql_id having sum(s.table_name. dba_indexes d.pl.name.index_name = p.owner. d.name and s.'mm/dd/rr hh24').owner. object_owner owner.sql_id = p.snap_id = sn. p.sql_id and d.segment_name and seg.table_name.snap_id and s. dba_hist_snapshot sn.blocks order by 1 asc.snap_id = sn. object_name name from dba_hist_sql_plan pl where operation = 'INDEX' and options = 'RANGE SCAN') p where d. object_name name from dba_hist_sql_plan pl where operation = 'INDEX' and options = 'UNIQUE SCAN') p where d. p. p.executions_delta) nbr_scans from dba_hist_sqlstat s.owner. .owner having sum(s.p.sql_id = p.sql_id.p.executions_delta) > 9 group by to_char(sn. seg. d.table_name.

status) €where tablespace_name = fs_ts_name union all select d. nvl (sum (bytes).tablespace_name.0)) '%' as pct_free from (select tablespace_name. contact info@rampant. 2) as used_space. To license this script for a commercial purpose.spool off ---------- spacesum8i. to_char ( nvl ( €round ( (100 * sum_free_blocks / sum_alloc_blocks).bytes / 1024 / 1024).tablespace_name (+) = b. 2) as total_free. round (((total_space . . 0) / 1024 / 1024).tablespace_name fs_ts_name. autoextend.bytes. round ((total_free_space / 1024 / 1024).bytes / 1024 / 1024) (nvl (t. 0) as total_free_space. Use at your own risk. 2). round ((total_space / 1024 / 1024).sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.tablespace_name. round ((a. autoextend. (select b.cc ************************************************* select tablespace_name.total_free_space) / 1024 / 1024). sum (bytes) as total_space from dba_data_files group by tablespace_name).2). 2) as total_space. 2). round ((a. sum (blocks) as sum_free_blocks from dba_free_space a. €€€sum (blocks) sum_alloc_blocks. max (autoextensible) autoextend.tablespace_name group by b. dba_tablespaces b where a.

round (nvl (t.tablespace_name.tablespace_name = a. (select tablespace_name.dba_data_files b. (select tablespace_name.filext$ c select €where c. '990. ---------- datafileae. To license this script for a commercial purpose. 2).file# (+)= b.00') from sys.tablespace_name (+) d.This script is free for non-commercial purposes .bytes.inc.Copyright © 2005 by Rampant TechPress -.dba_tablespaces d.extent_management like 'LOCAL' d.tablespace_name = t.null.sql -.'no'.cc ************************************************* b.v_$temp_extent_pool group by tablespace_name) t €where and and and €order d.'yes') autoextend from sys. Use at your own risk. 1. decode(c.bytes * 100. sum (bytes_cached) bytes from sys. to_char (100 . contact info@rampant. b.contents like 'TEMPORARY' by 1. 0) / 1024 / 1024.file_id €order by 2. sys.************************************************* -.file_name. 0)).(nvl (t.tablespace_name (+) d. max (autoextensible) autoextend.bytes / a. sum (bytes) bytes from dba_temp_files group by tablespace_name) a.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. -tsfrag.

inc.inc.------ with no warranties. b.filext$ c select €where b.tablespace_name.null. decode(c.bytes) / 1024000).2)) largest_chunk.2). 0. 2). sys. contact info@rampant. decode(c.0.tablespace_name = a. Use at your own risk.'no'.2).sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.dba_free_space group by tablespace_name order by 2 desc. ---------- dffrag.file_name.bytes) / 1024000). To license this script for a commercial purpose. decode ( round ((max (a. 2)) largest_chunk from sys.0) fragmentation_index from sys.'no'.null.0) fragmentation_index. b. null.blocks)) )).tablespace_name (+) and c.cc ************************************************* b.cc ************************************************* select tablespace_name.blocks)/ sum(a.null. nvl(round(sqrt(max(a.blocks))*(100/sqrt(sqrt(count(a. decode(round((max(bytes) / 1024000).file_id and b. count (*) free_chunks.file_name.2). round ((max (a.'yes') autoextend.'yes'). 1.file_id (+) €group by b. Use at your own risk. round((max(bytes) / 1024000). €€€€nvl(round(sqrt(max(blocks)/sum(blocks))* (100/sqrt(sqrt(count(blocks)) )). To license this script for a commercial purpose. contact info@rampant.tablespace_name €order . count(*) free_chunks.dba_free_space a.dba_data_files b. sys.file_id = a.file# (+)= a.

sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. ' ' object_type. blocks select from sys. bytes / 1024. Use at your own risk. file_id.' partition_name). ---------- tsmap8. blocks from sys. segment_type. contact info@rampant.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. 1.dba_free_space where tablespace_name = <:tablespace name> union all select owner. Use at your own risk. bytes / 1024 size_kb. To license this script for a commercial purpose. ' ' object_name.by 5 desc.null. decode (partition_name. contact info@rampant.segment_name '. ---------- maxext8. €€€€block_id.segment_name.5. To license this script for a commercial purpose.cc ************************************************* 'free space' object_owner. block_id.dba_extents where tablespace_name = <:tablespace name> order by 4.cc ************************************************* . file_id.

---------- objdef.tablespace_name.cc ************************************************* select a. a.segment_name '.segment_name.tablespace_name = b.3.extents <= 5 and segment_type <> 'CACHE' order by 1. segment_type. To license this script for a commercial purpose.2.dba_free_space c where a. sys.NULL.tablespace_name) group by a. max(c. contact info@rampant.dba_free_space b where a. next_extent. max_extents. a.tablespace_name = c.segment_name. tablespace_name from sys. decode(partition_name.segment_type.tablespace_name and b. a. a.owner. a. a. Use at your own risk.next_extent > (select max(bytes) from sys.segment_name.tablespace_name and a.select owner.next_extent. a.dba_segments where max_extents .bytes) max_contig_space from sys.next_extent .' partition_name) segment_name. a. initial_extent.tablespace_name.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.segment_type.tablespace_name = c.dba_segments a. extents.owner.

Use at your own risk.null. €seg_name varchar2(100). €fs4 number.space_usage ( segment_owner => rec.cc ************************************************* drop type BlckFreeSpaceSet. contact info@rampant.owner.null. fulb number. u_b number. fs2_bl number.null. fs2_b number. drop type BlckFreeSpace.null.null.null ).null.segment_type) ) loop dbms_space. fs3_b number. seg_type in varchar2 default null) return BlckFreeSpaceSet pipelined is outRec BlckFreeSpace := BlckFreeSpace(null. fs1_bl number. €fs2 number. create type BlckFreeSpaceSet as table of BlckFreeSpace. create or replace function BlckFreeSpaceFunc (seg_owner IN varchar2. To license this script for a commercial purpose. €fs1 number. begin for rec in (select s.---------- awr_list_seg_block_space. €seg_type varchar2(30). fs4_b number. . segment_name => rec. u_bl number.segment_type from dba_segments s w here owner = seg_owner and segment_type = nvl(seg_type. fs1_bytes => fs1_b. create type BlckFreeSpace as object ( €seg_owner varchar2(30).segment_name.segment_name. €fb number €).segment_type.s. fs4_bl number. €fs3 number.s. fulbl number. segment_type => rec.owner.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. fs3_bl number. fs1_b number.

999 9. fs3_b.fs1 outRec.fs3 outRec. u_b outRec. fs2_b.segment_name. fulb.cc ************************************************* col seg_owner heading 'Segment Owner' format a10 col seg_type heading 'Segment Type' format a10 col seg_name heading 'Segment Name' format a30 col col col col col fs1 fs2 fs3 fs4 fb heading heading heading heading heading '0-25% Free Space' '25-50% Free Space' '50-75% Free Space' '75-100% Free Space' 'Full Blocks' format format format format format 9. contact info@rampant. fulbl.fs4 outRec.segment_type. fs4_b.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. outRec. u_bl. fs3_bl. fs4_bl.fb := := := := := fs1_bl. outRec. fs4_bl. Pipe Row (outRec). To license this script for a commercial purpose.fs2 outRec. / ---------- awr_report_seg_block_space. fulbl.seg_type := rec.999 9. Use at your own risk.999 accept user_name prompt break on seg_owner select Enter Segment Owner: . outRec.seg_owner := rec. end.999 9. return.999 9.fs1_blocks €€fs2_bytes fs2_blocks fs3_bytes fs3_blocks fs4_bytes fs4_blocks full_bytes full_blocks unformatted_blocks unformatted_bytes ). fs3_bl.seg_name := rec. end loop. => => => => => => => => => => => fs1_bl. fs2_bl. fs2_bl.owner.

---------- awr_estimate_index_cost.put_line ('Allocated Bytes = ' a_bytes).create_index_cost ( ddl => 'create index stats$sysstat_idx on stats$sysstat ' '(value) tablespace sysaux'. alloc_bytes => a_bytes ). Use at your own risk.* from Table ( BlckFreeSpaceFunc ('&user_name'. contact info@rampant.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. Use at your own risk. / ---------- workspace_status.put_line ('Used Bytes = ' u_bytes). a_bytes number.cc ************************************************* WORKSPACE FORMAT a10 HEADING 'Workspace' owner FORMAT a10 HEADING 'Owner' freeze_status FORMAT a8 HEADING 'Freeze Status' resolve_status FORMAT a8 HEADING 'Resolve Status' parent_workspace FORMAT a10 HEADING 'Parent Workspace' freeze_mode FORMAT a8 HEADING 'Freeze Mode' COLUMN COLUMN COLUMN COLUMN COLUMN COLUMN ttitle 'Workspace Status' . dbms_output. dbms_output. end. used_bytes => u_bytes.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. begin dbms_space. contact info@rampant. To license this script for a commercial purpose. To license this script for a commercial purpose. 'TABLE' ) ) order by fs4 desc .cc ************************************************* declare u_bytes number.

spool off ttitle off ---------- pga_advice. Use at your own risk. Use at your own risk. To license this script for a commercial purpose.spool workspace_status select workspace. owner.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.cc ************************************************* select grantee from sys. resolve_status from dba_workspaces . NVL(freeze_mode.cc ************************************************* ttitle 'PGA Target Advice Report' set lines 80 pages 47 spool pga_advice SELECT round(PGA_TARGET_FOR_ESTIMATE/1024/1024) target_mb. contact info@rampant.dba_role_privs where . freeze_status. ESTD_PGA_CACHE_HIT_PERCENTAGE cache_hit_perc.'NONE') freeze_mode.'NONE') parent_workspace. NVL(parent_workspace. ESTD_OVERALLOC_COUNT FROM v$pga_target_advice / spool off ttitle off ---------- dbagranted. To license this script for a commercial purpose.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. contact info@rampant.

privilege.'SYSTEM').cc ************************************************* select grantee.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. 'BECOME USER'. Use at your own risk. ---------- sensprivs. privilege.granted_role = 'DBA' and grantee not in ('SYS'.dba_sys_privs where (privilege like '%ANY%' or privilege like '%DROP%' or privilege in ('ALTER SYSTEM'. 'ALTER TABLESPACE'. €'BECOME USER'. admin_option from sys. 'UNLIMITED TABLESPACE')) and .dba_roles) union all select grantee.dba_sys_privs where €(privilege like '%ANY%' or privilege like '%DROP%' or privilege in ('ALTER SYSTEM'. To license this script for a commercial purpose. 'UNLIMITED TABLESPACE')) and grantee not in ('SYS'. contact info@rampant.'SYSTEM') and grantee not in (select role from sys. 'ALTER TABLESPACE'. admin_option from sys.

'IMP_FULL_DATABASE'. 'OEM_MONITOR'. .sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.user$ a.tempts# = tts. 'SYSTEM') order by 1.name = 'SYSTEM') and a.name not in ('SYS'. 'SYSTEM') union select grantee.cc ************************************************* select a. To license this script for a commercial purpose. 'EXP_FULL_DATABASE')).ts$ dts. 'AQ_ADMINISTRATOR_ROLE'.datats# = dts.ts$ tts where (a.dba_roles where role not in ('DBA'. 'SYSTEM') union select username.grantee not in ('SYS'. ---------- badstorage. sys.name username.'system as default' privilege from sys.name = 'SYSTEM' or tts.ts# and a.'unlimited tablespace' from dba_sys_privs where privilege = 'unlimited tablespace' and grantee not in ('SYS'.'system quotas' from sys.'SYSTEM') and grantee in (select role from sys. contact info@rampant. sys. 'SNMPAGENT'. Use at your own risk.dba_ts_quotas where tablespace_name = 'system' and username not in ('SYS'.ts#) and (dts.

v_$sort_segment order by 1.'CACHE') group by owner order by 2 desc).2) pct_of_database select from (select owner .2) space_used_mb. free_extents. Use at your own risk. contact info@rampant. total_extents.cc ************************************************* tablespace_name.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. round(100 * (byte_count / tot_bytes). max_used_size. Use at your own risk. ---------- sortusage. contact info@rampant.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.dba_segments).dba_segments where segment_type not in ('TEMPORARY'. . sum(bytes) as byte_count from sys. To license this script for a commercial purpose. (select sum(bytes) as tot_bytes from sys.cc ************************************************* €€owner. round((byte_count / 1024 / 1024). current_users. max_sort_size select from sys.---------- totuserspace. To license this script for a commercial purpose. used_extents.

maxval "Maximum Value". sys.cc ************************************************* select metric_name Metric Name . blocks select from sys. sys. To license this script for a commercial purpose. contact info@rampant.address and a.session_addr = c.v_$sqlarea b.v_$session c where €€a. ---------- metric_summary.hash_value and a. Use at your own risk.---------- sortdet. c.cc ************************************************* sql_text.sqlhash = b.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. machine. tablespace. sid. average "Average Value" from DBA_HIST_SYSMETRIC_SUMMARY where snap_id = &pEndSnap and dbid = &pDbId .saddr order by sid.v_$sort_usage a. Use at your own risk.sqladdr = b. metric_unit "Metric Unit".sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. minval "Minimum Value".username. contact info@rampant. To license this script for a commercial purpose. extents.

stat_name "Statistic Name" e.snap_id = b.instance_number = &pInstNum and b. 'workarea memory allocated' ) and e.snap_id = &pBgnSnap and e.instance_number and b1.instance_number and e1.startup_time = e1.instance_number = b.value and e.dba_hist_snapshot e1 where b1.instance_number = &pInstNum and e. contact info@rampant.startup_time and b1.end_interval_time) )*60*6 select .dbid = e.b.instance_number = e.snap_id and e1. dba_hist_sysstat e €where b.value .end_interval_time) )*60 + extract( second from (e1.value > 0 €order by 1 asc .sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.end_interval_time) )*24*6 extract( hour from (e1.snap_id = e. ( 0*60+ 0+ extract( minute from (e1.value)/ select avg( extract( day from (e1.b.stat_id and e. Use at your own risk.snap_id = &pEndSnap and b.end_interval_time < e1.dbid and b1.end_interval_time)) ) from dba_hist_snapshot b1 .value "Total" round((e.dbid = b.end_interval_time-b1.end_interval_time-b1.dbid = &pDbId and e. . 'opened cursors current' .value >= b.end_interval_time-b1.stat_id €€€€€€€€= e.end_interval_time ).dbid = &pDbId and b.snap_id and b1.end_interval_time-b1.dbid and e1. To license this script for a commercial purpose.value .and instance_number = &pInstNum ---------- sys_stat_int_10g.2) "Per Second" €from dba_hist_sysstat b €.stat_name not in ( 'logons current' .cc ************************************************* e.

end_interval_time-b1.2)) "Per Second" €from dba_hist_osstat b . contact info@rampant.---------- os_stat_int_10g.value > 0 €order by 1 asc .instance_number = &pInstNum and e.instance_number = e.stat_name.end_interval_time ).stat_id and e.end_interval_time) )*60*6 0+ €extract( minute from (e1.stat_name "Statistic Name" . to_number(null) .stat_name.end_interval_time)) ) from dba_hist_snapshot b1 .instance_number and e1. 0.end_interval_time) )*24*6 0*60+ extract( hour from (e1.snap_id = b.dbid and b1.end_interval_time-b1.end_interval_time) )*60+ extract( second from (e1.cc ************************************************* select e.value .stat_id = e.end_interval_time-b1.value >= b.b.instance_number and b1.value and e.dbid and e1.dbid = e. 'NUM_CPUS'.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.dbid = &pDbId and e.snap_id and b1.dbid = &pDbId and b.value.dba_hist_snapshot e1 where b1.snap_id = &pBgnSnap and e.startup_time and b1.end_interval_time-b1.snap_id = &pEndSnap and b.end_interval_time < e1.instance_number = b.b. e.dbid = b.value .value)/( select avg( extract( day from (e1.snap_id = e.instance_number = &pInstNum and b. To license this script for a commercial purpose.snap_id and e1. round((e. decode(e. e. 'BYTES'). decode( instrb(e. Use at your own risk.startup_time €€= e1. dba_hist_osstat e €where b.value) "Total" .