--Code Depot --Oracle Tuning --The Definitive Reference --Alexey B. Danchenkov and Donald K.

Burleson --ISBN 0-9744486-2-1€€ --(c) 2006 by Rampant TechPress - All rights reserved. --No portions of this code may be distributed without the express consent of Ram pant TechPress --These scripts are free for non-commercial use without any warranties. --Use at your own risk!

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

--oracle10g_quick.ksh -- ************************************************* -- 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 -- ************************************************* spool rpt_last.lst set pages 9999; set feedback on; set verify off; column reads format 999,999,999 column writes format 999,999,999 select to_char(sn.end_interval_time,'yyyy-mm-dd HH24'), (newreads.value-oldreads.value) reads, (newwrites.value-oldwrites.value) writes from dba_hist_sysstat oldreads, dba_hist_sysstat newreads, dba_hist_sysstat oldwrites, dba_hist_sysstat newwrites, dba_hist_snapshot sn where newreads.snap_id = (select max(sn.snap_id) from dba_hist_snapshot) and newwrites.snap_id = (select max(sn.snap_id) from dba_hist_snapshot) and oldreads.snap_id = sn.snap_id-1 and oldwrites.snap_id = sn.snap_id-1

and and and and ; prompt prompt prompt prompt prompt prompt prompt prompt prompt prompt prompt prompt prompt prompt prompt prompt prompt prompt

oldreads.stat_name = 'physical reads' newreads.stat_name = 'physical reads' oldwrites.stat_name = 'physical writes' newwrites.stat_name = 'physical writes' *********************************************************** This will identify any single file who's read I/O is more than 10% of the total read I/O of the database. The "hot" file should be examined, and the hot table/index should be identified using STATSPACK. - The busy file should be placed on a disk device with "less busy" files to minimize read delay and channel contention. - If small file has a hot small table, place the table in the KEEP pool - If the file has a large-table full-table scan, place the table in the RECYCLE pool and turn on parallel query for the table. ***********************************************************

column mydate format a16 column file_name format a40 column reads format 999,999,999 select to_char(sn.end_interval_time,'yyyy-mm-dd HH24') mydate, new.filename file_name, new.phyrds-old.phyrds reads from dba_hist_filestatxs old, dba_hist_filestatxs new, dba_hist_snapshot snw here sn.snap_id = (select max(snap_id) from dba_hist_snapshot) and new.snap_ id = sn.snap_id and old.snap_id = sn.snap_id-1 and new.filename = old.filename --and -- new.phyrds-old.phyrds > 10000 and (new.phyrds-old.phyrds)*10 > ( select (newreads.value-oldreads.value) reads from dba_hist_sysstat oldreads, dba_hist_sysstat newreads, dba_hist_snapshot sn1 where sn.snap_id = sn1.snap_id and newreads.snap_id = sn.snap_id and oldreads.snap_id = sn.snap_id-1 and oldreads.stat_name = 'physical reads' and newreads.stat_name = 'physical reads' and (newreads.value-oldreads.value) > 0) ;

prompt prompt prompt prompt prompt prompt prompt prompt prompt prompt prompt prompt prompt prompt prompt

*********************************************************** This will identify any single file who's write I/O is more than 10% of the total write I/O of the database. The "hot" file should be examined, and the hot table/index should be identified using STATSPACK. - The busy file should be placed on a disk device with "less busy" files to minimize write delay and channel channel contention. - If small file has a hot small table, place the table in the KEEP pool ***********************************************************

column mydate format a16 column file_name format a40 column writes format 999,999,999 select to_char(sn.end_interval_time,'yyyy-mm-dd HH24') mydate, new.filename file_name, new.phywrts-old.phywrts writes from dba_hist_filestatxs old, dba_hist_filestatxs new, dba_hist_snapshot sn where sn.snap_id = (select max(snap_id) from dba_hist_snapshot) and new.snap_id = sn.snap_id and old.snap_id = sn.snap_id-1 and new.filename = old.filename --and ---- new.phywrts-old.phywrts > 10000 and (new.phywrts-old.phywrts)*10 > (select(newwrites.value-oldwrites.value) writes from dba_hist_sysstat oldwrites, dba_hist_sysstat newwrites, dba_hist_snapshot sn1 where sn.snap_id = sn1.snap_id and newwrites.snap_id = sn.snap_id and oldwrites.snap_id = sn.snap_id-1 and oldwrites.stat_name = 'physical writes' and newwrites.stat_name = 'physical writes' and (newwrites.value-oldwrites.value) > 0) ; prompt *********************************************************** prompt The data buffer hit ratio is controlled by the db_block_buffer or db_cac he_size parameters. prompt *********************************************************** column column column column logical_reads format 999,999,999 phys_reads format 999,999,999 phys_writes format 999,999,999 "BUFFER HIT RATIO" format 999

snap_id-1 and f.namespace and new. select to_char(sn.value-e.value)) / ((a.value))) ) < 90 --and sn. (new. d.value-f.namespace. dba_hist_sysstat c. new. dba_hist_sysstat g. column column column column mydate heading 'Yr.value "phys_writes".value-e.stat_name = 'physical writes' .gets-old.snap_id = sn.gets) hit_ratio.snap_id and d.snap_id = sn.stat_name = 'physical reads' and d. new.end_interval_time.snap_id = sn.999. dba_hist_snapshot sn where new.snap_id-1 and g.snap_id = sn.gets-old.' format a16 999.snap_id = sn.snap_id and b.pins-old.value))-(c.value-g.stat_name = 'consistent gets' and e.snap_id and old.value-e.value)+(b.(round(100 * (((a.pins-old.snap_id = sn.snap_id and e.value-f.value-g.'dd Mon HH24:mi:ss') mydate. dba_hist_sysstat e. reloads format hit_ratio format pin_hit_ratio format Mo Dy Hr.pinhits-old.value)+(b.pinhits)/(new.snap_id = new.snap_id = sn. . dba_hist_sysstat f.namespace = new. (new.stat_name = 'db block gets' and c.stat_name = 'consistent gets' and b.value-e.999 999.value))-(c.snap_id = (select max(snap_id) from dba_hist_snapshot) and a.snap_id = sn.gethits)/(new.value-f. dba_hist_snapshot sn where -.gethits-old.value)) --/ ((a.stat_name = 'physical reads' and g.value))) "BUFFER HIT RATIO" from dba_hist_sysstat a.pins > 0 .gets > 0 and new.value)+(b. dba_hist_librarycache new.end_interval_time.99 999.stat_name = 'db block gets' and f. dba_hist_sysstat d.value)+(b.'yyyy-mm-dd HH24') mydate.select to_char(sn.pins) pin_hit_ratio.snap_id-1 and old. round(100 * (((a.snap_id and c. dba_hist_sysstat b.99 break on mydate skip 2.reloads from dba_hist_librarycache old.snap_id-1 and a.value-f.

dba_hist_sysstat newdsk.value)/(newmem.value-oldmem. 191 "High Performance Oracle8 Tuning" by Don Burleson *********************************************************** break on snapdate skip 2 column snapdate format a16 column filename format a40 select to_char(sn. newdsk.value) ratio from dba_hist_sysstat oldmem.snap_id = sn.wait_count waits from dba_hist_filestatxs old. or adding indexes to force index_full scans *********************************************************** column sorts_memory format 999.999 column sorts_disk format 999.prompt prompt prompt prompt *********************************************************** When there are high disk sorts.value-oldmem.value > 0 . you should investigate increasing sort_area_size.999.value-olddsk. dba_hist_sysstat olddsk.snap_id = sn.stat_name = 'sorts (memory)' and newmem.value > 100 --and sn.'dd Mon HH24:mi:ss') mydate.snap_id and olddsk.newdsk. dba_hist_snapshot sn where -. (newdsk. dba_hist_filestatxs new.9999999999999 select to_char(sn.value-olddsk.snap_id-1 and newmem.value sorts_disk. new.end_interval_time.stat_name = 'sorts (disk)' and newdsk.value-olddsk. newmem.filename.snap_id-1 and oldmem. prompt prompt prompt prompt prompt prompt prompt prompt *********************************************************** When there is high I/O waits.wait_count-old.snap_id and oldmem.end_interval_time.Where there are more than 100 disk sorts per hour -.value-oldmem.snap_id = sn.999 column ratio format .stat_name = 'sorts (disk)' and newmem. disk bottlenecks may exist Run iostats to find the hot disk and shuffle files to remove the contention See p.'dd Mon HH24:mi:ss') mydate. dba_hist_sysstat newmem.snap_id = (select max(snap_id) from dba_hist_snapshot) and newdsk.value sorts_memory.stat_name = 'sorts (memory)' and olddsk.snap_id = sn. old. dba_hist_snapshot sn where .999.

snap_id = sn.snap_id = (select max(snap_id) from dba_hist_snapshot) and new.snap_id and new.'dd Mon HH24:mi:ss') .and and and and .snap_id = sn.value-oldmem.wait_count-old.999.999 select to_char(sn.'dd Mon HH24:mi:ss') mydate.wait_count > 0 new. sn.snap_id = (select max(snap_id) from dba_hist_snapshot) new. *********************************************************** prompt prompt prompt prompt column buffer_busy_wait format 999.value-oldmem.999. Find the offending table and add more freelists. dba_hist_snapshot sn where sn.value redo_log_space_requests from dba_hist_sysstat oldmem.stat_name = 'redo log space requests' and newmem.snap_id-1 --having -.999 select to_char(sn. blob) .snap_id = sn.filename = new.'dd Mon HH24:mi:ss') mydate.snap_id-1 and oldmem.snap_id old.snap_id and oldmem.snap_id = sn.filename old.snap_id = sn. dba_hist_buffer_pool_stat new.buffer_busy_wait-old.stat_name = 'redo log space requests' and newmem. newmem. dba_hist_snapshot sn where sn. avg(new.snap_id = sn.end_interval_time.end_interval_time.end_interval_time.value > 30 and newmem.avg(new.buffer_busy_wait-old.buffer_busy_wait) > 100 group by to_char(sn.value > 0 . or prompt fetches of long datatypes (long raw.newmem. prompt *********************************************************** prompt Table fetch continued row indicates chained rows.snap_id = (select max(snap_id) from dba_hist_snapshot) --and -.snap_id = sn.buffer_busy_wait) buffer_busy_wait from dba_hist_buffer_pool_stat old. prompt prompt prompt prompt *********************************************************** High redo log space requests indicate a need to increase the log_buffer parameter *********************************************************** column redo_log_space_requests format 999.snap_id-1 *********************************************************** Buffer Bury Waits may signal a high update table with too few freelists.value-oldmem. dba_hist_sysstat newmem.snap_id and old.

sql prompt .Place the table in the RECYCLE pool prompt .value enqueue_deadlocks from dba_hist_sysstat a. a.Make the offending tables parallel query prompt (alter table xxx parallel degree yyy.value) table_fetch_continued_row from dba_hist_sysstat oldmem.snap_id and a.end_interval_time. dba_hist_snapshot sn where sn.snap_id = sn.stat_name = 'table fetch continued row' --and -.snap_id = sn.end_interval_time.999 column enqueue_deadlocks select to_char(sn. run access.end_interval_time. Investigate increasing shared_pool_size *********************************************************** format 999. dba_hist_snapshot sn where sn.'dd Mon HH24:mi:ss') .Build an index on the table to remove the FTS prompt prompt To locate the table.value) > 10000 group by to_char(sn. prompt *********************************************************** prompt Long-table full table scans can indicate a need to: prompt prompt .prompt prompt Investigate increasing db_block_size or reorganizing tables prompt with chained rows.value-oldmem.newmem.snap_id = (select max(snap_id) from dba_hist_snapshot) and a.value-oldmem.999.value-oldmem. dba_hist_sysstat newmem.) prompt .snap_id = (select max(snap_id) from dba_hist_snapshot) and newmem. avg(newmem.snap_id and oldmem.'dd Mon HH24:mi:ss') mydate.value > 0 --having -.avg(newmem.stat_name = 'table fetch continued row' and newmem. prompt prompt *********************************************************** column table_fetch_continued_row format 999.stat_name = 'enqueue deadlocks' .snap_id = sn. prompt prompt prompt prompt prompt prompt *********************************************************** Enqueue Deadlocks indicate contention within the Oracle shared pool.snap_id-1 and oldmem.999 select to_char(sn.999.'dd Mon HH24:mi:ss') mydate.

from dba_hist_snapshot) (long tables)' (long tables)' -. --. -. spool off.stat_name = 'table scans . .To license this script for a commercial purpose.ksh -.stat_name = 'table scans and newmem. Mon HH24:mi:ss') mydate. snap_id.************************************************* #!/bin/ksh # First.'dd newmem.snap_id-1 and oldmem.cc -. . s perfstat/perfstat<<! . ORACLE_SID=$ORACLE_SID export ORACLE_SID ORACLE_HOME=`cat /etc/oratab grep ^$ORACLE_SID: cut -f2 -d':'` export ORACLE_HOME PATH=$ORACLE_HOME/bin:$PATH export PATH echo "Please enter the number of seconds between snapshots. Use at your own risk.end_interval_time.999. we must set the environment .snap_id and oldmem.snap_id = sn.contact info@rampant." read elapsed $ORACLE_HOME/bin/sqlplus execute statspack.value-oldmem. dba_hist_sysstat newmem.Copyright © 2005 by Rampant TechPress -.with no warranties.************************************************* -.oracle9i_quick.snap_id = (select max(snap_id) and newmem. .snap.value fts from dba_hist_sysstat oldmem.This script is free for non-commercial purposes -. exit ! sleep $elapsed $ORACLE_HOME/bin/sqlplus s perfstat/perfstat<<! execute statspack. dba_hist_snapshot sn where sn.snap_id = sn.prompt *********************************************************** column fts format 999.999 select to_char(sn. select name.snap.

stats$snapshot sn where newreads.snap_id = sn.snap_id) from stats$snapshot) and newwrites. column reads format 999. and the hot table/index should be identified using STATSPACK.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.999.snap_id = (select max(sn. perfstat.snap_id = sn.999 column writes format 999. ---------- oracle9i_rpt_last.statistic# = 40 and oldwrites. perfstat. perfstat.to_char(snap_time.stats$sysstat newwrites.stats$sysstat oldreads. set feedback on.cc ************************************************* spool rpt_last. contact info@rampant.snap_id) from stats$snapshot) and oldreads. (newwrites.stats$sysstat oldwrites.stats$sysstat newreads.value) reads.snap_id-1 and oldwrites.snap_id = (select max(sn. .value-oldwrites.' dd Mon YYYY HH24:mi:ss') from stats\$snapshot.The busy file should be placed on a disk device with "less busy" files to minimize read delay and channel contention. Use at your own risk. .statistic# = 41 and newwrites.statistic# = 41 .lst set pages 9999. The "hot" file should be examined.999.999 select to_char(snap_time.'yyyy-mm-dd HH24'). prompt prompt prompt prompt prompt prompt prompt prompt prompt prompt *********************************************************** This will identify any single file who's read I/O is more than 10% of the total read I/O of the database. perfstat.value) writes from perfstat. (newreads. To license this script for a commercial purpose. v\$database where snap_id > (select max(snap_id)-2 from stats\$snapshot) .statistic# = 40 and newreads.snap_id-1 and oldreads.value-oldreads. set verify off.

perfstat.snap_id and old.phyrds-old. new.999 select to_char(snap_time.phyrds > 10000 and (new. The "hot" file should be examined.statistic# = 40 and (newreads. prompt *********************************************************** column mydate format a16 column file_name format a40 column reads format 999.stats$sysstat oldreads.value-oldreads.value-oldreads.new.snap_id = sn. and the hot table/index should be identified using STATSPACK.stats$filestatxs new. .If small file has a hot small table.value) > 0 ) .phyrds)*10 > ( select (newreads.statistic# = 40 and newreads.stats$sysstat newreads. perfstat.phyrds-old.999.snap_id-1 and oldreads.snap_id and newreads. prompt prompt prompt prompt prompt prompt prompt prompt prompt prompt prompt prompt prompt *********************************************************** This will identify any single file who's write I/O is more than 10% of the total write I/O of the database.snap_id = sn1.stats$snapshot sn where sn. new.phyrds reads from perfstat.snap_id = sn. perfstat.snap_id = sn.value) reads from perfstat.stats$filestatxs old.snap_id = sn.phyrds-old. .If small file has a hot small table. place the table prompt in the KEEP pool prompt prompt .stats$snapshot sn1 where sn.filename file_name.snap_id and oldreads.snap_id-1 and new.filename --and -.'yyyy-mm-dd HH24') mydate.filename = old. place prompt the table in the RECYCLE pool and turn on parallel query prompt for the table.prompt prompt .snap_id = (select max(snap_id) from stats$snapshot) and new.The busy file should be placed on a disk device with "less busy" files to minimize write delay and channel channel contention. perfstat.If the file has a large-table full-table scan. place the table in the KEEP pool .

filename --and ---.999.v alue-e.filename = old.value-f.new.statistic# = 40 and newwrites. perfstat.statistic# = 40 and (newwrites.'dd Mon HH24:mi:ss') mydate.value)+(b.999 "BUFFER HIT RATIO" format 999 select to_char(snap_time.999.snap_id = (select max(snap_id) from stats$snapshot) and new.value-oldwrites.999 phys_reads format 999.999 phys_writes format 999.stats$sysstat a.ora parameter *********************************************************** logical_reads format 999.filename file_name.phywrts-old.stats$snapshot sn1 where sn.999. d. perfstat.phywrts-old.snap_id-1 and oldwrites.value-oldwrites.value-f.prompt prompt *********************************************************** column mydate format a16 column file_name format a40 column writes format 999.value) writes from perfstat.value)+(b. perfstat.'yyyy-mm-dd HH24') mydate. . perfstat. new.snap_id = sn.value "phys_writes".snap_id and oldwrites.stats$sysstat newwrites.value)) / ((a.snap_id = sn.999.value-e.snap_id = sn.phywrts > 10000 and (new. you should consider adding to the db_block_buffer init.snap_id and newwrites.value-g.stats$sysstat b.stats$sysstat oldwrites.value))) "BUFFER HIT RATIO" from perfstat.999 select to_char(snap_time.value) > 0 ) . round(100 * (((a. prompt prompt prompt prompt column column column column *********************************************************** When the data buffer hit ratio falls below 90%.stats$filestatxs new.stats$filestatxs old. perfstat. new.value))-(c.snap_id and old.phywrts)*10 > ( select (newwrites.phywrts-old.snap_id = sn1.stats$snapshot sn where sn.phywrts writes from perfstat.snap_id = sn.snap_id-1 and new.

stats$sysstat f.'yyyy-mm-dd HH24') mydate. reloads format hit_ratio format pin_hit_ratio format Mo Dy Hr.pins) pin_hit_ratio.snap_id = sn.value-g.value-e.snap_id-1 and g.pins-old.snap_id = sn.snap_id = (select max(snap_id) from stats$snapshot) and a.snap_id = sn.snap_id = sn.snap_id = sn.stats$sysstat d.999 column ratio format . column column column column mydate heading 'Yr. new.value-f. prompt prompt prompt prompt *********************************************************** When there are high disk sorts.namespace = new.statistic# = 38 and f.snap_id and d.statistic# = 40 and g. (new.pins > 0 .statistic# = 40 and d.value-e.gets > 0 and new.snap_id and b.reloads from stats$librarycache old. new.stats$sysstat g. select to_char(snap_time.stats$sysstat e.snap_id = new.stats$snapshot sn where -.999. perfstat.gethits-old.statistic# = 38 and c.perfstat.9999999999999 .(round(100 * (((a.gets) hit_ratio.snap_id = sn. you should investigate increasing sort_area_size. or adding indexes to force index_full scans *********************************************************** column sorts_memory format 999.pinhits-old.pinhits)/(new.gethits)/(new.snap_id-1 and a.value)+(b.999 999.gets-old.pins-old.gets-old. (new.statistic# = 39 and e.value))-(c.value-f.namespace. stats$librarycache new.stats$sysstat c.namespace and new. stats$snapshot sn where new.999 column sorts_disk format 999.999.statistic# = 39 and b.snap_id and c. perfstat. perfstat.99 999.snap_id = sn.snap_id and old.snap_id and e.snap_id = sn.value)+(b.' format a16 999. perfstat.statistic# = 41 .snap_id-1 and f.99 break on mydate skip 2. perfstat.snap_id-1 and old.value))) ) < 90 --and sn.999.value)) / (( a.

perfstat.stats$sysstat newdsk.newdsk. 191 "High Performance Oracle8 Tuning" by Don Burleson *********************************************************** break on snapdate skip 2 column snapdate format a16 column filename format a40 select to_char(snap_time.value-oldmem.value sorts_disk.value)/(newmem.'dd Mon HH24:mi:ss') mydate.snap_id = sn.wait_count > 0 and new.snap_id-1 and oldmem.value) ratio from perfstat.snap_id = sn. disk bottlenecks may exist Run iostats to find the hot disk and shuffle files to remove the contention See p. (newdsk.name = 'sorts (disk)' and newmem.name = 'sorts (memory)' and newmem.name = 'sorts (disk)' and newdsk.value-olddsk.stats$sysstat olddsk.wait_count-old.stats$sysstat oldmem.name = 'sorts (memory)' and olddsk. prompt prompt prompt prompt prompt prompt prompt prompt *********************************************************** When there is high I/O waits.value-oldmem.value > 0 .stats$filestatxs new.value-olddsk. prompt *********************************************************** prompt Buffer Bury Waits may signal a high update table with too .snap_id = (select max(snap_id) from stats$snapshot) and newdsk. perfstat.stats$snapshot sn where sn.snap_id = sn. new.value sorts_memory. perfstat.value-oldmem. newdsk. perfstat.filename.'dd Mon HH24:mi:ss') mydate.stats$snapshot sn where -.filename = new.snap_id and oldmem. perfstat.snap_id-1 .stats$sysstat newmem.snap_id-1 and newmem. perfstat.Where there are more than 100 disk sorts per hour -.snap_id and olddsk.snap_id and old.stats$filestatxs old. newmem.select to_char(snap_time.snap_id = (select max(snap_id) from stats$snapshot) and new.wait_count waits from perfstat.value-olddsk.filename and old.snap_id = sn. old.wait_count-old.snap_id = sn.snap_id = sn.value > 100 --and sn.

value > 30 and newmem.stats$sysstat oldmem.'dd Mon HH24:mi:ss') mydate. perfstat.999.name = 'redo log space requests' and newmem.snap_id = (select max(snap_id) from stats$snapshot) --and -. newmem. perfstat. or fetches of long datatypes (long raw. perfstat.999.stats$sysstat newmem.snap_id-1 --having -. prompt *********************************************************** column buffer_busy_wait format 999.value-oldmem.avg(new.999 select .snap_id = sn.999 select to_char(snap_time.newmem.snap_id = sn. blob) Investigate increasing db_block_size or reorganizing tables with chained rows.stats$buffer_pool_statistics new.stats$snapshot sn where sn.prompt few freelists.value-oldmem.buffer_busy_wait) > 100 group by to_char(snap_time.snap_id = sn.'dd Mon HH24:mi:ss') mydate.'dd Mon HH24:mi:ss') . perfstat. avg(new.snap_id = (select max(snap_id) from stats$snapshot) and new.snap_id = sn.snap_id and oldmem.value > 0 .buffer_busy_wait-old. prompt prompt prompt prompt *********************************************************** High redo log space requests indicate a need to increase the log_buffer parameter *********************************************************** column redo_log_space_requests format 999. *********************************************************** column table_fetch_continued_row format 999.buffer_busy_wait-old. prompt prompt prompt prompt prompt prompt prompt prompt *********************************************************** Table fetch continued row indicates chained rows.stats$snapshot sn where sn.value redo_log_space_requests from perfstat.name = 'redo log space requests' and newmem. Find the offending table and add more freelists.999.snap_id and old.buffer_busy_wait) buffer_busy_wait from perfstat.value-oldmem.999 select to_char(snap_time.snap_id-1 and oldmem.snap_id and new.snap_id = sn.stats$buffer_pool_statistics old.

stats$sysstat oldmem.snap_id = (select max(snap_id) from stats$snapshot) and newmem.stats$snapshot sn where sn.value-oldmem.value > 0 --having -.999 select to_char(snap_time.newmem.stats$sysstat newmem.'dd Mon HH24:mi:ss') mydate.Build an index on the table to remove the FTS To locate the table.stats$sysstat oldmem.value-oldmem.statistic# = 24 .snap_id = sn. Investigate increasing shared_pool_size *********************************************************** format 999.Make the offending tables parallel query (alter table xxx parallel degree yyy.snap_id = sn.name = 'table fetch continued row' --and -. run access.stats$snapshot sn where sn.sql *********************************************************** column fts format 999.) . perfstat.'dd Mon HH24:mi:ss') mydate.snap_id and a.'dd Mon HH24:mi:ss') . .'dd Mon HH24:mi:ss') mydate.value fts from perfstat.snap_id and oldmem.999.value) > 10000 group by to_char(snap_time.avg(newmem. perfstat.name = 'table fetch continued row' and newmem. prompt prompt prompt prompt prompt prompt prompt prompt prompt prompt prompt *********************************************************** Long-table full table scans can indicate a need to: .snap_id = (select max(snap_id) from stats$snapshot) and a.value enqueue_deadlocks from perfstat.value-oldmem.999.value) table_fetch_continued_row from perfstat.snap_id = sn.stats$sysstat a. perfstat.snap_id-1 and oldmem.to_char(snap_time.999 column enqueue_deadlocks select to_char(snap_time.value-oldmem. a. avg(newmem. newmem. prompt prompt prompt prompt prompt prompt *********************************************************** Enqueue Deadlocks indicate contention within the Oracle shared pool.Place the table in the RECYCLE pool .

stat_name = 'physical writes' and newwrites.stat_name = 'physical writes' .snap_id = sn. column reads format 999.999.stat_name = 'physical reads' and oldwrites. (newwrites.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. perfstat. spool off. .value-oldwrites.lst set pages 9999. prompt *********************************************************** prompt This will identify any single file who's read I/O prompt is more than 10% of the total read I/O of the database.end_interval_time.statistic# = 140 and newmem.value) writes from dba_hist_sysstat oldreads.cc ************************************************* spool rpt_last.snap_id = sn.snap_id = sn.999 column writes format 999. (newreads. Use at your own risk.stat_name = 'physical reads' and newreads.stats$snapshot sn where sn. set feedback on.value) reads.snap_id = sn. ---------- oracle10g_rpt_last.stats$sysstat newmem.statistic# = 140 .snap_id = (select max(snap_id) from stats$snapshot) and newmem. contact info@rampant.snap_id and oldmem.value-oldreads.snap_id = (select max(sn.snap_id = (select max(sn.snap_id) from dba_hist_snapshot) and newwrites. To license this script for a commercial purpose.snap_id-1 and oldmem. dba_hist_sysstat newwrites. dba_hist_sysstat newreads.999 select to_char(sn. dba_hist_sysstat oldwrites.999.snap_id-1 and oldwrites.'yyyy-mm-dd HH24').snap_id) from dba_hist_snapshot) and oldreads.snap_id-1 and oldreads. set verify off.perfstat. dba_hist_snapshot sn where newreads.

The busy file should be placed on a disk device with "less busy" files to minimize write delay and channel channel contention. prompt prompt prompt prompt prompt prompt prompt prompt prompt prompt *********************************************************** This will identify any single file who's write I/O is more than 10% of the total write I/O of the database.value-oldreads.snap_id = sn. .phyrds)*10 > (select(newreads.snap_id-1 and oldreads.filename file_name.value) > 0) .snap_id and oldreads.end_interval_time.999.value-oldreads. dba_hist_filestatxs new.snap_id-1 and new. new.prompt prompt prompt prompt prompt prompt prompt prompt prompt prompt prompt prompt prompt prompt prompt The "hot" file should be examined.phyrds > 10000 and (new.snap_id and old.phyrds-old.If the file has a large-table full-table scan.stat_name = 'physical reads' and newreads.phyrds reads from dba_hist_filestatxs old. *********************************************************** column mydate format a16 column file_name format a40 column reads format 999. . .The busy file should be placed on a disk device with "less busy" files to minimize read delay and channel contention.stat_name = 'physical reads' and (newreads. dba_hist_snapshot sn where sn.value) reads from dba_hist_sysstat oldreads.'yyyy-mm-dd HH24') mydate.filename --and -.snap_id = sn.snap_id = sn. . dba_hist_sysstat newreads.snap_id and newreads. place the table in the KEEP pool .phyrds-old.999 select to_char(sn.snap_id = (select max(snap_id) from dba_hist_snapshot) and new.snap_id = sn. and the hot table/index should be identified using STATSPACK. place the table in the RECYCLE pool and turn on parallel query for the table.filename = old. and the hot table/index should be identified using STATSPACK.new.snap_id = sn1.If small file has a hot small table.phyrds-old. new. dba_hist_snapshot sn1 where sn. The "hot" file should be examined.

value-e.snap_id and newwrites.value "phys_writes". dba_hist_sysstat newwrites.999 phys_reads format 999.new.snap_id-1 and oldwrites.phywrts-old.snap_id = sn. new.snap_id and oldwrites. place the table prompt in the KEEP pool prompt prompt *********************************************************** column mydate format a16 column file_name format a40 column writes format 999.stat_name = 'physical writes' and newwrites.value))) "BUFFER HIT RATIO" from dba_hist_sysstat a.value-oldwrites.filename file_name.snap_id = (select max(snap_id) from dba_hist_snapshot) and new.value) writes from dba_hist_sysstat oldwrites.snap_id = sn1. round(100 * (((a.value)+(b. you should consider adding to the db_block_buffer init.999.999 phys_writes format 999.prompt prompt . new.value)) / ((a.999.value)+(b.value-oldwrites.phywrts > 10000 and (new.phywrts)*10 > (select (newwrites.phywrts-old. .999 "BUFFER HIT RATIO" format 999 select to_char(sn.'yyyy-mm-dd HH24') mydate.stat_name = 'physical writes' and (newwrites. dba_hist_sysstat b.ora parameter *********************************************************** logical_reads format 999.If small file has a hot small table. dba_hist_snapshot sn where sn. dba_hist_sysstat c.value-f.snap_id = sn.end_interval_time.999.value-g.999 select to_char(sn.999. prompt prompt prompt prompt column column column column *********************************************************** When the data buffer hit ratio falls below 90%.snap_id = sn.phywrts-old.value-f.snap_id = sn. d.snap_id-1 and new.filename --and ---. dba_hist_filestatxs new.end_interval_time. dba_hist_snapshot sn1 where sn.'dd Mon HH24:mi:ss') mydate.value-e.phywrts writes from dba_hist_filestatxs old.snap_id and old.filename = old.value) > 0) .value))-(c.

or adding indexes to force index_full scans *********************************************************** column sorts_memory format 999.value-f.pins) pin_hit_ratio.snap_id = sn.value-e.reloads from dba_hist_librarycache old.(round(100 * (((a.snap_id = sn.999 column ratio format .value))-(c. dba_hist_sysstat g.snap_id = new.99 999.' format a16 999.stat_name = 'physical writes' .snap_id = (select max(snap_id) from dba_hist_snapshot) and a.pinhits-old.value)+(b. reloads format hit_ratio format pin_hit_ratio format Mo Dy Hr. new.snap_id and b.pinhits)/(new.value)+(b.stat_name = 'db block gets' and c. dba_hist_snapshot sn where -.snap_id and d.value-g.snap_id-1 and f.stat_name = 'physical reads' and g.gets-old.pins-old.snap_id and c. prompt prompt prompt prompt *********************************************************** When there are high disk sorts. you should investigate increasing sort_area_size. dba_hist_snapshot sn where new.snap_id = sn. dba_hist_sysstat e.end_interval_time.namespace and new. dba_hist_librarycache new.gets > 0 and new.gets) hit_ratio.snap_id-1 and g.999.999 column sorts_disk format 999.999.snap_id and e.snap_id = sn.gethits-old.snap_id = sn. new.'yyyy-mm-dd HH24') mydate.dba_hist_sysstat d. (new.stat_name = 'consistent gets' and b.gets-old.9999999999999 .snap_id = sn.gethits)/(new.snap_id-1 and a.99 break on mydate skip 2.snap_id and old.999. select to_char(sn.namespace = new. (new.stat_name = 'db block gets' and f.value)) --/ ((a.snap_id = sn.value-f. dba_hist_sysstat f.value))) ) < 90 --and sn.pins > 0 .999 999.snap_id-1 and old.pins-old. column column column column mydate heading 'Yr.stat_name = 'physical reads' and d.stat_name = 'consistent gets' and e.snap_id = sn.value-e.namespace.

191 "High Performance Oracle8 Tuning" by Don Burleson *********************************************************** break on snapdate skip 2 column snapdate format a16 column filename format a40 select to_char(sn. prompt *********************************************************** prompt Buffer Bury Waits may signal a high update table with too prompt few freelists.stat_name = 'sorts (memory)' and olddsk.snap_id = sn.filename = new.value-olddsk. newdsk.wait_count waits from dba_hist_filestatxs old.newdsk.stat_name = 'sorts (disk)' and newmem.'dd Mon HH24:mi:ss') mydate.wait_count-old. Find the offending table and add more freelists.select to_char(sn. new.value) ratio from dba_hist_sysstat oldmem. (newdsk.snap_id = (select max(snap_id) from dba_hist_snapshot) and new.snap_id = sn.value)/(newmem.snap_id = sn. dba_hist_sysstat newdsk. old.snap_id and oldmem.snap_id and olddsk.value > 0 .Where there are more than 100 disk sorts per hour -.wait_count > 0 and new.value > 100 --and sn. dba_hist_filestatxs new. dba_hist_sysstat newmem.snap_id = sn.filename and old. dba_hist_snapshot sn where -.snap_id-1 and newmem. prompt prompt prompt prompt prompt prompt prompt prompt *********************************************************** When there is high I/O waits.wait_count-old. .stat_name = 'sorts (disk)' and newdsk.filename. dba_hist_sysstat olddsk.snap_id-1 and oldmem.'dd Mon HH24:mi:ss') mydate.end_interval_time.snap_id-1 .value-oldmem. dba_hist_snapshot sn where sn.snap_id = sn.value-olddsk.snap_id and old.snap_id = (select max(snap_id) from dba_hist_snapshot) and newdsk.value-oldmem.value-olddsk. disk bottlenecks may exist Run iostats to find the hot disk and shuffle files to remove the contention See p.snap_id = sn.end_interval_time. newmem.value-oldmem.stat_name = 'sorts (memory)' and newmem.value sorts_memory.value sorts_disk.

newmem.999 select to_char(sn. avg(new.value redo_log_space_requests from dba_hist_sysstat oldmem.snap_id = sn.'dd Mon HH24:mi:ss') .stat_name = 'redo log space requests' and newmem.buffer_busy_wait-old.end_interval_time.snap_id = (select max(snap_id) from dba_hist_snapshot) and new.snap_id-1 --having -. or fetches of long datatypes (long raw.snap_id and oldmem. dba_hist_buffer_pool_stat new. dba_hist_snapshot sn where sn. blob) Investigate increasing db_block_size or reorganizing tables with chained rows. *********************************************************** column table_fetch_continued_row format 999.999.buffer_busy_wait) > 100 group by to_char(sn.999 select to_char(sn.value-oldmem.value > 30 and newmem.'dd Mon HH24:mi:ss') mydate.prompt *********************************************************** column buffer_busy_wait format 999.999 select to_char(sn.value > 0 .snap_id = sn.buffer_busy_wait-old.'dd Mon HH24:mi:ss') mydate.999.end_interval_time.stat_name = 'redo log space requests' and newmem.value-oldmem.snap_id = (select max(snap_id) from dba_hist_snapshot) --and -.end_interval_time.buffer_busy_wait) buffer_busy_wait from dba_hist_buffer_pool_stat old.snap_id and new. dba_hist_snapshot sn where sn. prompt prompt prompt prompt prompt prompt prompt prompt *********************************************************** Table fetch continued row indicates chained rows. dba_hist_sysstat newmem. .snap_id-1 and oldmem.snap_id = sn.snap_id = sn.snap_id and old. newmem. prompt prompt prompt prompt *********************************************************** High redo log space requests indicate a need to increase the log_buffer parameter *********************************************************** column redo_log_space_requests format 999.avg(new.999.snap_id = sn.end_interval_time.value-oldmem.'dd Mon HH24:mi:ss') mydate.

value > 0 --having -.avg(newmem.stat_name = 'table fetch continued row' --and -. dba_hist_snapshot sn where sn.999.avg(newmem. newmem.stat_name = 'enqueue deadlocks' .value) table_fetch_continued_row from dba_hist_sysstat oldmem. a.Make the offending tables parallel query (alter table xxx parallel degree yyy.value-oldmem.value-oldmem. .end_interval_time.999 column enqueue_deadlocks select to_char(sn.Place the table in the RECYCLE pool .'dd Mon HH24:mi:ss') mydate.snap_id and a.999 select to_char(sn.stat_name = 'table fetch continued row' and newmem. prompt prompt prompt prompt prompt prompt *********************************************************** Enqueue Deadlocks indicate contention within the Oracle shared pool.snap_id = sn. run access.snap_id and oldmem. dba_hist_sysstat newmem.) . Investigate increasing shared_pool_size *********************************************************** format 999.value-oldmem.'dd Mon HH24:mi:ss') mydate.sql *********************************************************** column fts format 999.snap_id-1 and oldmem.end_interval_time.snap_id = (select max(snap_id) from dba_hist_snapshot) and a.snap_id = (select max(snap_id) from dba_hist_snapshot) and newmem.value) > 10000 group by to_char(sn.end_interval_time.newmem. prompt prompt prompt prompt prompt prompt prompt prompt prompt prompt prompt *********************************************************** Long-table full table scans can indicate a need to: . dba_hist_snapshot sn where sn.999.'dd Mon HH24:mi:ss') .value-oldmem.value fts from dba_hist_sysstat oldmem.value enqueue_deadlocks from dba_hist_sysstat a. dba_hist_sysstat newmem.snap_id = sn.Build an index on the table to remove the FTS To locate the table.snap_id = sn.

pins-old.************************************************* -.snap_id-1 and oldmem. column column column column mydate heading 'Yr.pins-old.pins) sum(new. To license this script for a commercial purpose.reloads)/ sum(new.snap_id = new. Mo Dy Hr. c2.'yyyy-mm-dd HH24') sum(new. stats$snapshot sn where new.snap_id = sn. library_cache_miss_ratio -------- rpt_10g_lib_miss. select to_char(snap_time.reloads-old. Use at your own risk.999.namespace group by to_char(snap_time.99999 break on mydate skip 2.999 999.rpt_lib_miss_oracle9i.reloads) sum(new.snap_id = sn. -.stat_name = 'table scans (long tables)' and newmem.with no warranties.dba_hist_snapshot sn where sn.snap_id = (select max(snap_id) from dba_hist_snapshot) and newmem.snap_id-1 and old.reloads-old.************************************************* set lines 80. Use at your own risk. spool off. -.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. --. mydate.Copyright © 2005 by Rampant TechPress -. .snap_id = sn.To license this script for a commercial purpose.999 9.stat_name = 'table scans (long tables)' .This script is free for non-commercial purposes -.contact info@rampant.999.namespace = new.sql -. c1.snap_id and oldmem.'yyyy-mm-dd HH24') .' c1 heading "execs" c2 heading "Cache Misses While Executing" c3 heading "Library Cache Miss Ratio" format format format format a16 9.pins) from stats$librarycache old. set pages 999.snap_id and old. stats$librarycache new.cc -.

************************************************* -.************************************************* set lines 100 set pages 999 column column column column column column column c1 c2 c3 c4 c5 c6 c7 heading heading heading heading heading heading heading 'Pool Size(M)' 'Size Factor' 'Est LC(M) ' 'Est LC Mem. column column column column mydate heading 'Yr.contact info@rampant.contact info@rampant.reloads)/ sum(new. estd_lc_memory_objects estd_lc_time_saved c5.with no warranties. c4. sum(new. dba_hist_snapshot sn where new.pins) library_cache_miss_ratio from dba_hist_librarycache old.snap_id-1 and old. Mo Dy Hr.99999 break on mydate skip 2. c2.reloads) c2.namespace = new. set pages 999. estd_lc_time_saved_factor c6.'yyyy-mm-dd HH24') . -.To license this script for a commercial purpose.999.999. Obj.999.999 999.namespace group by to_char(sn.'yyyy-mm-dd HH24') mydate.pins-old. dba_hist_librarycache new.' c1 heading "execs" c2 heading "Cache Misses While Executing" c3 heading "Library Cache Miss Ratio" format format format format a16 9.-.cc -.end_interval_time. sum(new.snap_id = new. SELECT shared_pool_size_for_estimate shared_pool_size_factor estd_lc_size c3.cc -.snap_id and old.This script is free for non-commercial purposes -. select to_char(sn. sum(new.999 c1.snap_id = sn.reloads-old.' 'Est Time Saved (sec)' 'Est Parse Saved Factor' 'Est Object Hits' format 999.sql -. Use at your own risk.pins) c1. --.reloads-old.999 9.Copyright © 2005 by Rampant TechPress -.shared_pool_advice. estd_lc_memory_object_hits c7 FROM . -.end_interval_time.************************************************* set lines 80.pins-old.

contact info@rampant. . alter system set shared_pool_size=500m. . alter system set db_cache_size=1500m.************************************************* -. we must set the environment .************************************************* #!/bin/ksh # First. . -.cc -.To license this script for a commercial purpose.change_sga.with no warranties. ORACLE_SID=$1 export ORACLE_SID ORACLE_HOME=`cat /etc/oratab grep ^$ORACLE_SID: cut -f2 -d':'` #ORACLE_HOME=`cat /var/opt/oracle/oratab grep ^$ORACLE_SID: cut -f2 -d':'` export ORACLE_HOME PATH=$ORACLE_HOME/bin:$PATH export PATH $ORACLE_HOME/bin/sqlplus s /nologin<<! connect system/manager as sysdba. -. . -.with no warranties.cc -.dss_config. --.************************************************* -.This script is free for non-commercial purposes -. --. ORACLE_SID=$1 export ORACLE_SID ORACLE_HOME=`cat /etc/oratab grep ^$ORACLE_SID: cut -f2 -d':'` #ORACLE_HOME=`cat /var/opt/oracle/oratab grep ^$ORACLE_SID: cut -f2 -d':'` export ORACLE_HOME PATH=$ORACLE_HOME/bin:$PATH export PATH $ORACLE_HOME/bin/sqlplus s /nologin<<! connect system/manager as sysdba.************************************************* #!/bin/ksh # First. . alter system set db_cache_size=1500m.ksh -. we must set the environment .contact info@rampant. alter system set shared_pool_size=500m. . .To license this script for a commercial purpose.ksh -. Use at your own risk. alter system set pga_aggregate_target=4000m.This script is free for non-commercial purposes -. Use at your own risk. alter system set pga_aggregate_target=4000m.Copyright © 2005 by Rampant TechPress -. exit ! -.v$shared_pool_advice.Copyright © 2005 by Rampant TechPress -.

with no warranties. alter system set db_cache_size=4000m. . --.contact info@rampant.dbid = fu. Use at your own risk. 'FALSE'. 'MM/DD/YYYY.description from wri$_dbu_usage_sample samp. last_sample_period. last_sample_date. --. exit ! -. 'FALSE') currently_used.************************************************* #!/bin/ksh # First.Copyright © 2005 by Rampant TechPress -. samp. HH:MI:SS').To license this script for a commercial purpose. . detected_usages. wri$_dbu_feature_metadata mt where samp.************************************************* -.name.with no warranties. ORACLE_SID=$1 export ORACLE_SID ORACLE_HOME=`cat /etc/oratab grep ^$ORACLE_SID: cut -f2 -d':'` #ORACLE_HOME=`cat /var/opt/oracle/oratab grep ^$ORACLE_SID: cut -f2 -d':'` export ORACLE_HOME PATH=$ORACLE_HOME/bin:$PATH export PATH $ORACLE_HOME/bin/sqlplus s /nologin<<! connect system/manager as sysdba.dbid and samp. aux_count. Use at your own risk.ksh -.This script is free for non-commercial purposes -. -. alter system set shared_pool_size=500m.dbid.This script is free for non-commercial purposes -.AWR_usage.************************************************* -.sql -. first_usage_date.oltp_config. alter system set pga_aggregate_target=1500m. mt. . wri$_dbu_feature_usage fu. 'TRUE'. to_char(last_sample_date.version and . sample_interval. we must set the environment .cc -.Copyright © 2005 by Rampant TechPress -.************************************************* select samp.version. total_samples. HH:MI:SS').version = fu. 'MM/DD/YYYY.exit ! -.contact info@rampant. last_usage_date. -. feature_info. fu. NULL. decode(to_char(last_usage_date.cc -.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.cc ************************************************* break on begin_interval_time skip 2 column phyrds format 999. prompt set pages 999 break on snap_time skip 2 accept stat_name char prompt 'Enter Statistic Name: '.name and fu. Use at your own risk.999. col snap_time col value select format a19 format 999. contact info@rampant. 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.name = mt. filename.999. Use at your own risk.fu. To license this script for a commercial purpose.999 column begin_interval_time format a25 select begin_interval_time. 4) != 4 /* filter out disabled features */ ---------- phys_disk_reads_10g. accept stat_value number prompt 'Enter Statistics Threshold value: '. ---------- rpt_10g_sysstat.999 .name not like '_DBFUS_TEST%' and /* filter out test features */ bitand(mt.cc ************************************************* prompt prompt This will query the dba_hist_sysstat to display all values prompt that exceed the value specified in prompt the "where" clause of the query.usg_det_method. phyrds from dba_hist_filestatxs natural join dba_hist_snapshot .

'yyyy-mm-dd hh24:mi') snap_time. To license this script for a commercial purpose. ---------- hot_write_files_10g. Use at your own risk. filename.'yyyy-mm-dd hh24:mi').'yyyy-mm-dd hh24:mi') snap_time.999 format a20 select to_char(begin_interval_time. phywrts from dba_hist_filestatxs natural join dba_hist_snapshot where phywrts > 0 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 . contact info@rampant.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.999.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. 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.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.cc ************************************************* prompt prompt This will query the dba_hist_sysstat view to display prompt average values by day-of-the-week prompt . ---------- rpt_sysstat_dy_10g. To license this script for a commercial purpose. Use at your own risk.'yyyy-mm-dd hh24:mi'). ---------- rpt_sysstat_hr_10g.'hh24'). 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. col snap_time col avg_value format a19 format 999. phywrts desc.) order by to_char(begin_interval_time. contact info@rampant. 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.999 select to_char(begin_interval_time. Use at your own risk.'hh24') snap_time. To license this script for a commercial purpose.'hh24') order by to_char(begin_interval_time.cc ************************************************* prompt This will query the dba_hist_sysstat view to prompt display average values by hour of the day set pages 999 break on snap_time skip 2 accept stat_name char prompt 'Enter Statistics Name: '.

'day') snap_time.1. 'thursday'. contact info@rampant. 'friday'. 'saturday'. 'wednesday'.cc ************************************************* prompt prompt This will compare values from dba_hist_waitstat with prompt detail information from dba_hist_active_sess_history.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. 'monday'. 'tuesday'. 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. ---------- wait_time_detail_10g. To license this script for a commercial purpose.4.999.5.'day') order by decode( to_char(begin_interval_time. col snap_time col avg_value format a19 format 999. 'sunday'. 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 .6.999 select to_char(begin_interval_time.7 ) .3. Use at your own risk.2.set pages 999 accept stat_name char prompt 'Enter Statistic Name: '.'day').

total_waits /(a. dba_objects obj where wait.total_waits /(a.event = 'db file scattered read' and b.snap_id = snap. dba_data_files df.'yyyy-mm-dd hh24:mi').999 heading 'Time' format 999.total_waits) (b. v$system_event b where a. -.average_wait b.999 select to_char(begin_interval_time. object_name. To license this script for a commercial purpose.average_wait / a.snap_id and wait. dba_hist_active_sess_history ash.col wait_count col time heading 'Wait Count' format 999. ---------col col col col col optimizer_index_cost_adj. dba_hist_snapshot snap.current_obj# and wait_count > 50 order by to_char(begin_interval_time.99 999 select a.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.object_id = ash.file_id = ash.snap_id = ash.999 9999.total_waits) b.'yyyy-mm-dd hh24:mi') snap_time.average_wait)*100 from v$system_event a. time from dba_hist_waitstat wait.average_wait a.total_waits + b.999 9.99 9.cc ************************************************* c1 c2 c3 c4 c5 heading heading heading heading heading 'Average Waits for Full Scan Read I/O' 'Average Waits for Index Read I/O' 'Percent of I/O Waits for Full Scans' 'Percent of I/O Waits for Index Scans' 'Starting Value for optimizer index cost adj' c1. Use at your own risk.event = 'db file sequential read' .file_name.current_file# and obj. c3.snap_id and df. wait_count. c2.total_waits + b. c4. contact info@rampant. c5 format format format format format 9999. file_name . . object_type.

-- reads_10g.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 -- ************************************************* break on begin_interval_time skip 2 column phyrds format 999,999,999 column begin_interval_time format a25 select begin_interval_time, filename, phyrds from dba_hist_filestatxs natural join dba_hist_snapshot;

-- wt_events_int_10g.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 event , waits "Waits" , time "Wait Time (s)" , pct*100 "Percent of Tot" , waitclass "Wait Class" from (select e.event_name event , e.total_waits - nvl(b.total_waits,0) waits , (e.time_waited_micro - nvl(b.time_waited_micro,0))/100000 0 time , (e.time_waited_micro - nvl(b.time_waited_micro,0))/ (select sum(e1.time_waited_micro - nvl(b1.time_waited_mic ro,0)) from dba_hist_system_event b1 , dba_hist_system_event e1 where b1.snap_id(+) = b.snap_id and e1.snap_id = e.snap_id and b1.dbid(+) = b.dbid and e1.dbid = e.dbid and b1.instance_number(+) = b.instance_number and e1.instance_number = e.instance_number and b1.event_id(+) = e1.event_id and e1.total_waits > nvl(b1.total_waits,0) and e1.wait_class <> 'Idle' ) pct , e.wait_class waitclass

from dba_hist_system_event b dba_hist_system_event e where b.snap_id(+) and e.snap_id and b.dbid(+) and e.dbid and b.instance_number(+) and e.instance_number and b.event_id(+) and e.total_waits and e.wait_class order by time desc, waits desc )

, = &pBgnSnap = &pEndSnap = &pDbId = &pDbId = &pInstNum = &pInstNum = e.event_id > nvl(b.total_waits,0) <> 'Idle'

-- sys_event_int_10g.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 event "Event Name", waits "Waits", timeouts "Timeouts", time "Wait Time (s)", avgwait "Avg Wait (ms)", waitclass "Wait Class" from (select e.event_name event , e.total_waits - nvl(b.total_waits,0) waits , e.total_timeouts - nvl(b.total_timeouts,0) timeouts , (e.time_waited_micro - nvl(b.time_waited_micro,0))/1000000 time , decode ((e.total_waits - nvl(b.total_waits, 0)), 0, to_number(NULL) , ((e.time_waited_micro - nvl(b.time_waited_micro,0))/1000) / (e.total _waits - nvl(b.total_waits,0)) ) avgwait , e.wait_class waitclass from dba_hist_system_event b , dba_hist_system_event e where b.snap_id(+) = &pBgnSnap and e.snap_id = &pEndSnap and b.dbid(+) = &pDbId and e.dbid = &pDbId and b.instance_number(+) = &pInstNum and e.instance_number = &pInstNum and b.event_id(+) = e.event_id and e.total_waits > nvl(b.total_waits,0) and e.wait_class <> 'Idle' ) order by time desc, waits desc

----------

bg_event_int_10g.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 event "Event Name", waits "Waits", timeouts "Timeouts", time "Wait Time (s)", avgwait "Avg Wait (ms)", waitclass "Wait Class" from (select e.event_name event , e.total_waits - nvl(b.total_waits,0) waits , e.total_timeouts - nvl(b.total_timeouts,0) timeouts , (e.time_waited_micro - nvl(b.time_waited_micro,0))/1000000 time , decode ((e.total_waits - nvl(b.total_waits, 0)), 0, to_number(NULL) , ((e.time_waited_micro - nvl(b.time_waited_micro,0))/1000) / (e.total _waits - nvl(b.total_waits,0)) ) avgwait , e.wait_class waitclass from dba_hist_bg_event_summary b , dba_hist_bg_event_summary e where b.snap_id(+) = &pBgnSnap and e.snap_id = &pEndSnap and b.dbid(+) = &pDbId and e.dbid = &pDbId and b.instance_number(+) = &pInstNum and e.instance_number = &pInstNum and b.event_id(+) = e.event_id and e.total_waits > nvl(b.total_waits,0) and e.wait_class <> 'Idle' ) order by time desc, waits desc

----------

wait_stat_int_10g.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 ************************************************* "E.CLASS" "Waits"

select e.class , e.wait_count - nvl(b.wait_count,0)

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

instance_number b.999 select e.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.b. minval "Minimum Value".dbid(+) = &pDbId e.eq_type(+) = e.dbid(+) = e. To license this script for a commercial purpose.and and and and and and and and and and order b.999 column "Percent of Total DB Time" format 999. decode( e.eq_type by wttm desc.instance_number(+) = e.total_wait# . average "Average Value" from DBA_HIST_SYSMETRIC_SUMMARY where snap_id = &pEndSnap and dbid = &pDbId and instance_number = &pInstNum ---------- sys_time_model_int_10g.stat_name "Statistic Name" . Use at your own risk.eq_type b. 100*(e.req_reason(+) = e.dbid b.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.cc ************************************************* column "Statistic Name" format A40 column "Time (s)" format 999.value) "Time (s)" . to_number(null) . (e.b. Use at your own risk.value)/1000000 . metric_unit "Metric Unit".cc ************************************************* select metric_name Metric Name .value .type(+) = e.stat_name.nvl(b.0) > 0 l. contact info@rampant. contact info@rampant.total_wait#.instance_number = &pInstNum b. To license this script for a commercial purpose.value .dbid = &pDbId b.req_reason e.'DB time' . waits desc) ---------- metric_summary. maxval "Maximum Value".instance_number(+) = &pInstNum e.

dbid and b1.startup_time b1 e1 = b.instance_number = e1. contact info@rampant.instance_number and b1. .instance_number = e. dba_hist_sys_time_model b1 where b1.instance_number = and b. &pBgnSnap &pEndSnap &pDbId &pDbId &pInst_Num &pInst_Num e.dbid = e. Use at your own risk.dbid = b.instance_number and b1.cc ************************************************* e.dbid = e.instance_number = and e.instance_number = e.value).value .end_interval_time-b1.snap_id = e.end_interval_time-b1.instance_number = b.startup_time .end_interval_time-b1.snap_id = and b.value .stat_id ) "Percent of Total DB Time" from dba_hist_sys_time_model e .sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.stat_id = and e.dbid = and b.snap_id = e.end_interval_time-b1. To license this script for a commercial purpose.dbid = b.end_interval_time)) ) from dba_hist_snapshot .value .snap_id and e1.instance_number and e1.b.snap_id and e1.snap_id and b1.instance_number and e1.end_interval_time) )*24*6 extract( hour from (e1. dba_hist_sys_time_model b where b.value)/ select avg( extract( day from (e1.)/ ( select nvl((e1.stat_id = e1.value .b1.dba_hist_snapshot where b1.value "Total" round((e.snap_id = and e.dbid = and e.-1) from dba_hist_sys_time_model e1 .end_interval_time) )*60*6 select . ( 0*60+ 0+ extract( minute from (e1.snap_id and b1.snap_id = b.snap_id = b.end_interval_time) )*60 + extract( second from (e1.stat_name "Statistic Name" e.stat_id ---------- sys_stat_int_10g.value > 0 order by 2 desc.stat_name = 'DB time' and b1.dbid and e1.dbid and b1.b.dbid and e1.b.

to_number(decode(e.b. e.dbid = &pDbId and b. contact info@rampant.b. 'workarea memory allocated' ) and e. (e.immediate_misses) * 100 / (e. 'opened cursors current' .immediate_gets.misses.end_interval_time ).latch_hash = e.stat_name not in ( 'logons current' .cc ************************************************* select e.misses .dbid = &pDbId and b.misses.sleeps)/(e.wait_time . to_number(decode(e.snap_id = &pEndSnap and b.immediate_misses .wait_time)/1000000 "Wait Time (s)" .instance_number = &pInstNum and b.gets > 0 order by 1.gets.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.instance_number and b.b.latch_name "Latch Name" .b.value > 0 order by 1 asc ---------- latch_int_10g.instance_number = e. (e.instance_number = &pInstNum and e.value and e.b. null. to_number(decode(e.dbid = &pDbId and e.gets .gets "Get Requests" . e. Use at your own risk.gets.b. (e.b.stat_id = e.snap_id = &pBgnSnap and e. b.dbid and b.sleeps .and b1.misses .misses))) "Avg Sleeps / Miss" .b. dba_hist_latch e where b. null.gets .instance_number = &pInstNum and e. b. dba_hist_sysstat e where b.end_interval_time < e1. (e.gets))) "Percent Get Misses" .immediate_gets))) "Percent N o Wait Miss" from dba_hist_latch b .dbid = &pDbId and e.latch_hash and e.immediate_gets "No Wait Requests" .2) "Per Second" from dba_hist_sysstat b .b.dbid = e.value >= b.snap_id = &pBgnSnap and e.immediate_gets .instance_number = &pInstNum and b. null.stat_id and e.gets .b.misses) * 100/(e.snap_id = &pEndSnap and b.immediate_gets .immediate_gets. 4 . b.

nvl(b. e. where and and and and and and and and and and ) order ---------- lib_cache_int_10g.namespace "Name Space" .dbid b. waiter_sleeps "Waiter Sleeps" e.where_in_code(+) = e.pinhits .b.b.parent_name(+) = e.cc ************************************************* latchname "Latch Name".where_in_code latchname e.pins . contact info@rampant. To license this script for a commercial purpose. 3 desc select From ( select .instance_number = &pInstNum b.nvl(b.parent_name ' ' e.gets .nvl(b. . dba_hist_librarycache e .0) sleeps e.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.pins . to_number(decode(e.reloads .where_in_code e.snap_id = &pEndSnap b. e. Use at your own risk.b. Use at your own risk.0) by 1.null.invalidations "Invalidations" from dba_hist_librarycache b . e.b.gets .b. e. To license this script for a commercial purpose. contact info@rampant.gets.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.cc ************************************************* select b. to_number(decode(e.parent_name b. sleeps "Sleeps".reloads "Reloads" .b.instance_number b.0) nwmisses e.nwfail_count.sleep_count .gethits .pins))) "Pin Pct Miss" .sleep_count > nvl(b.snap_id(+) = &pBgnSnap e. 100 .b.gethits) * 100/(e.null.gets "Get Requests" .dbid(+) = &pDbId e.invalidations .gets.dbid = &pDbId b.(e.pinhits) * 100/(e.(e.0) waiter_sleeps dba_hist_latch_misses_summary b dba_hist_latch_misses_summary e b.b. .instance_number(+) = e.sleep_count.pins "Pin Requests" .sleep_count.b. 100 .b.wtr_slp_count . nwmisses "No Wait Misses".---------- latch_miss_int_10g.wtr_slp_count. from .pins.instance_number(+) = &pInstNum e.nwfail_count .pins.dbid(+) = e.gets))) "Get Pct Miss" .

e.dbid = &pDbId and b.snap_id b.gets > 0 ) order by param. contact info@rampant.instance_number = &pInstNum and e. Use at your own risk.null. gets "Get Requests". To license this script for a commercial purpose.gets.parameter = e.scans))) .snap_id = &pEndSnap and b.dbid b.scans .b.where and and and and and and and and b. getm "Pct Miss" From (select lower(b.instance_number e.instance_number = &pInstNum and b.b.b.dbid e. param gets getm scans scanm mods usage -------- Buf_pool_int_10g.snap_id = &pBgnSnap and e.dbid and b.usage from dba_hist_rowcache_summary b .modifications .gets .parameter) .b.snap_id e.dbid = e.scans .getmisses) * 100/(e.gets .b.instance_number and b.parameter and e.cc ************************************************* select param "Parameter".gets))) .instance_number b.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.b.getmisses . e.namespace = = = = = = = = = &pBgnSnap &pEndSnap &pDbId &pDbId e. e.namespace ---------- rowcache_int_10g.gets.scans .b.scans.b.gets .scans.instance_number e.dbid = &pDbId and e. (e. e. To license this script for a commercial purpose.dbid &pInstNum &pInstNum e.b. dba_hist_rowcache_summary e where b.b.modifications .instance_number = e. . (e.dbid b.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. to_number(decode(e. to_number(decode(e. Use at your own risk.gets .instance_number b.null.scanmisses .scanmisses) * 100/(e.

-.db_block_gets .db_block_gets . buffs "Buffer Gets" . fbwait "Free Buffer Waits" .consistent_gets.0) conget .consistent_gets .nvl(b.snap_id(+) = &pBgnSnap and e. e.dbid(+) = &pDbId and e.snap_id = &pEndSnap and b.physical_reads.0) + e.( (e. e.db_block_gets.write_complete_wait.0) fbwait .0)) / ( e.nvl(b.0) phwrite .set_msize numbufs .dbid and b.id(+) = e.nvl(b.0) bbwait from dba_hist_buffer_pool_stat b .nvl(b. numbufs "Number of Buffers" .consistent_gets . e. To license this script for a commercial purpose.instance_number(+) = e.name .nvl(b.0) phread . wcwait "Write Complete Waits" . bbwait "Buffer Busy Waits" .db_block_gets. e.nvl(b. to_number(null) .0) + e.nvl(b.physical_writes.db_block_gets.free_buffer_wait . e.free_buffer_wait. contact info@rampant.consistent_gets. dba_hist_buffer_pool_stat e where b.cc -.buffer_busy_wait . e. 0. decode( e.0) + e.instance_number and b. Use at your own risk. e.nvl(b.nvl(b.0) buffs .consistent_gets. phread "Physical Reads" .consistent_gets .physical_reads.write_complete_wait .physical_writes .nvl(b.instance_number(+) = &pInst_Num and e. (100* (1 .instance_number = &pInst_Num and b.physical_reads .************************************************* select name . poolhr "Pool Hit %" From (select e.consistent_gets.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.nvl(b. phwrite "Physical Writes" .0) .physical_reads .consistent_gets .nvl(b.0)) ) ) ) ) poolhr . e.dbid = &pDbId and b.0) wcwait .contact info@rampant.db_block_gets .buffer_busy_wait.nvl(b.dbid(+) = e. conget "Consistent Gets" .cc ************************************************* .id) order by 1 ---------- os_stat_int_10g.

dbid = &pDbId and b. round((e. e.stat_name. e. to_number(null) .end_interval_time-b1. contact info@rampant.stat_name "Statistic Name" .value)/( select avg( extract( day from (e1.value.dbid and e1.snap_id = b.value >= b.stat_id and e. .value .instance_number = &pInstNum and e. . Use at your own risk.instance_number and e1.value and e. . 'BYTES').snap_id = &pEndSnap and b.end_interval_time ).startup_time and b1.b.snap_id and e1.startup_time = e1.end_interval_time-b1.end_interval_time-b1.value) "Total" . .stat_name.end_interval_time) )*60 + extract( second from (e1. .sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.dbid = e.instance_number = &pInstNum and b.value > 0 order by 1 asc.instance_number and b1.end_interval_time-b1. .end_interval_time) )*60*6 0+ extract( minute from (e1. To license this script for a commercial purpose. ---------- high_sql_buf_gets.end_interval_time) )*24*6 0*60+ extract( hour from (e1. decode( instrb(e.b.value .select e.snap_id = e.snap_id = &pBgnSnap and e. .stat_id = e.dbid = b.2)) "Per Second" from dba_hist_osstat b . dba_hist_osstat e where b.cc ************************************************* sql_id buffer_gets_total executions_total buffer_gets_total/executions_total pct*100 cpu_time_total/1000000 elapsed_time_total/1000000 module stmt select .dbid = &pDbId and e. from "Buffer Gets" "Executions" "Gets / Exec" "% Total" "CPU Time (s)" "Elapsed Time (s)" "SQL Module" "SQL Statement" . 0.dbid and b1. decode(e. 'NUM_CPUS'.instance_number = e.end_interval_time)) ) from dba_hist_snapshot b1 .snap_id and b1.end_interval_time < e1.instance_number = b.dba_hist_snapshot e1 where b1.

instance_number(+) = e.nvl(b.'.sql_id = b.dbid(+) = b. object_type "Object Type" .(select e. where and and and and and and and and ) order by 2 desc.nvl(b1.sql_id sql_id .owner '. ratio "%Total" from( select n.buffer_gets_total .nvl(b.cpu_time_total . t.sql_id e.snap_id = e.cpu_time_total.instance_number b.snap_id(+) = @pBgnSnap b.0) buffer_gets_tot al . ---------- seg_top_logreads_10g. (e.dbid and b1. dba_hist_sysstat e1 where b1.nvl(b.sql_id(+) = e.stat_name = 'session logical reads' ) pct .null.sql_text stmt dba_hist_sqlstat e dba_hist_sqlstat b dba_hist_sqltext t b.dbid b.instance_number and b1.executions_total.subobject_name.0) from dba_hist_sysstat b1 .0)) > 0 t.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.instance_number(+) = b. contact info@rampant.nvl(b.executions_total.object_name decode(n.elapsed_time_total.' n.module . e.null.executions_total .nvl(b.dbid = &pDBId e.snap_id and b1.stat_id = e1.instance_number = e.instance_number and e1.value .instance_number = &pInstNum (e.snap_id and e1.cc ************************************************* select object_name "Object Name" .snap_id(+) = b.dbid and e1.dbid(+) = e.dbid = e.snap_id = &pEndSnap e.0))/ ( select e1.0) executions_total . e. e.sub object_name) object_name . To license this script for a commercial purpose. Use at your own risk.nvl(b. e. logical_reads_total "Logical Reads" .sql_id from .stat_id and e1.buffer_gets_total .buffer_gets_total. tablespace_name "Tablespace Name" .0) elapsed_time_ total .0) cpu_time_total .' n. e.executions_total . .buffer_gets_total.elapsed_time_total .value.

dba_hist_seg_stat b where b. Use at your own risk.nvl(b.dataobj# = r.dbid = 37933856 and b.ratio * 100.subobject_name) < 11 then n.dataobj# .dataobj# = b.nvl(b.nvl(b.tsname tbsp sum (e. To license this script for a commercial purpose. contact info@rampant. e. (select * from (select e.logical_reads_total. ---------- db_tbsp_io_10g. n.dbid ) order by logical_reads_total desc.subobject_name else substr(n.subobject_name.dbid = 37933856 and e. e. From ( select . e.snap_id = 2707 and b.logical_rea ds_total.length(n. 0) > 0 order by logical_reads_total desc) d where rownum <= 100) r where n. round(r.logical_reads_total .nvl(b.snap_id = 2694 and e. 0) log ical_reads_total .obj# and e.obj# = b.dataobj# and e.logical_reads_total .dbid = r.logical_reads_total .0)) + sum (e.0)) ios from dba_hist_filestatxs e .phyrds. 0)) over () ratio from dba_hist_seg_stat e .logical_reads_total.dbid .tablespace_name .subobject_name)-9) end subobject_name . n.obj# = r.obj# and n.phywrts.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.snap_id(+) = &pBgnSnap .. 2) ratio from dba_hist_seg_stat_obj n .cc ************************************************* tbsp Tablespace ios "I/O Activity" select .instance_number = 1 and e.nvl(b. case when length(n.phywrts . dba_hist_filestatxs b where b. ratio_to_report(e.obj# .phyrds .dataobj# and n.instance_number = 1 and e.logical_reads_total . e.object_type . r.

0) ) + (e. To license this script for a commercial purpose.file# and ( (e.file# = e.instance_number and b.nvl(b.instance_number(+) = e.tsname tbsp .phywrts .instance_number b.phyrds .dbid and b.phyrds .sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.file# = e.snap_id = &pEndSnap b.instance_number = &pInstNum b.dbid = &pDbId b.phywrts .dbid(+) = &pDbId and e.instance_number(+) = &pInstNum e.phyrds. extract( day from retention) *24*60+ extract( hour from retention) *60+ extract( minute from retention ) "Retention Interval" from dba_hist_wr_control. Use at your own risk. ----- wait_class_pct_ash.0)) + sum (e.dbid(+) = &pDbId e.instance_number(+) = e.0) ) + (e.dbid(+) = e.phyrds.instance_number(+) = &pInstNum and e.phyrds.nvl(b.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes .snap_id = &pEndSnap and b.snap_id(+) = &pBgnSnap and e.0)) ios from dba_hist_tempstatxs e .phywrts.dbid b.nvl(b.dbid(+) = e.phywrts.cc ************************************************* select extract( day from snap_interval) *24*60+ extract( hour from snap_interval) *60+ extract( minute from snap_interval ) "Snapshot Interval".phywrts .instance_number = &pInstNum and b.nvl(b.dbid = &pDbId and b.nvl(b.phywrts.nvl(b.tsname ) and and and and and and and and and ---------- awr_settings. sum (e.0) ) ) > 0 group by e.file# ( (e.0)) ) > 0 group by e.tsname union select e.e. contact info@rampant. dba_hist_tempstatxs b where b.phyrds .

total_waits. Use at your own risk. To license this script for a commercial purpose.999 PCT_TIME format 99.with no warranties. time_waited FROM v$system_wait_class WHERE wait_class != 'Idle'). (SELECT SUM(total_waits) sum_waits.2) pct_time FROM (SELECT wait_class. SUM(h.hot_files_ash.------ with no warranties. COUNT(*) Wait Number .file_name ORDER BY 3 DESC ----- events_waits_hr_ash.To license this script for a commercial purpose.2) pct_waits.time_waited) Total Time Waited FROM v$active_session_history h.999 PCT_WAITS format 99. ROUND(100 * (total_waits / sum_waits).sql -.file_name Data File . SUM(time_waited) sum_time FROM v$system_wait_class WHERE wait_class != 'Idle') ORDER BY 5 DESC.cc -.999.file_id GROUP BY f. ROUND(100 * (time_waited / sum_time). --.current_file# = f.cc ************************************************* TOTAL_WAITS format 999. contact info@rampant.This script is free for non-commercial purposes -.************************************************* SELECT f. Use at your own risk.99 TIME_WAITED format 999. time_waited. dba_data_files f WHERE h. total_waits.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes . -.contact info@rampant.Copyright © 2005 by Rampant TechPress -.************************************************* -. -.99 WAIT_CLASS format A20 column column column column column SELECT wait_class.999.

with no warranties.username ORDER BY 3 ---------- sql_waits_hr_ash.cc -.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.1/24 AND sysdate AND h.************************************************* SELECT s.event_id AND e.username IS NOT NULL GROUP BY s.This script is free for non-commercial purposes -. --. SUM(h. To license this script for a commercial purpose. Use at your own risk. v$session s.username.To license this script for a commercial purpose.wait_time + h.event_id = h.************************************************* -. --.with no warranties.To license this script for a commercial purpose.sql -. Use at your own risk.sid.sample_time BETWEEN sysdate .event_id AND e.wait_class <> 'Idle' AND s. v$event_name e WHERE h.event ORDER BY 2 DESC -. -.time_waited) "Total Wait Time" FROM v$active_session_history h.cc -.cc ************************************************* . -.wait_class <> 'Idle' GROUP BY h.event "Wait Event". SUM(h. v$event_name e WHERE h.time_waited) "total wait time" FROM v$active_session_history h.event_id = e.user_waits_hr_ash.sid.contact info@rampant.session_id = s.sample_time BETWEEN sysdate .sid AND e.Copyright © 2005 by Rampant TechPress -. s.contact info@rampant.1/24 AND sysdate AND h. Use at your own risk. s. contact info@rampant.************************************************* SELECT h.-.wait_time + h.

SUM(h.sql_id is not null AND e.object_name.sql_id AND h. Use at your own risk.************************************************* SELECT o.user_id AND h.To license this script for a commercial purpose.sql. dba_objects o.owner.with no warranties. o.event_id = h. o.Copyright © 2005 by Rampant TechPress -.1/24 AND sysdate AND h.user_id = u.wait_class <> 'Idle' GROUP BY o. sql.cc -.user_id. o.object_name.user_id.This script is free for non-commercial purposes -.object_waits_hr_ash.wait_time + h.time_waited) "total wait time" FROM v$active_session_history h. u. Use at your own risk.sql_id = sql.object_id AND e.sql_text.username ORDER BY 4 DESC -.sample_time BETWEEN sysdate . --.sample_time BETWEEN sysdate . .time_waited) "total wait time" FROM v$active_session_history h. v$event_name e WHERE h.username.contact info@rampant.1/24 AND sysdate AND h.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.SELECT h. dba_users u.owner. u.event_id = h. -. v$sqlarea sql.object_type ORDER BY 4 DESC ------- sess_waits_ash.sql_text.current_obj# = o. v$event_name e WHERE h.event_id AND e. o.object_type.wait_time + h.sql -. SUM(h.event_id AND e.************************************************* -.wait_class <> 'Idle' GROUP BY h.

class_waits_hr_ash.This script is free for non-commercial purposes -.contact info@rampant. round((a.To license this script for a commercial purpose. --.sid AND b. --.cc -. h. Use at your own risk.sql -.************************************************* SELECT b.average_waiter_count. -.3) time_secs FROM v$sess_time_model a.'hh24:mi:ss') "Begin". v$system_wait_class c WHERE c.contact info@rampant. a.wait_class "Wait Class".sid = 123 ORDER BY 3 DESC -.bhr_hr_ash.To license this script for a commercial purpose. Use at your own risk.cc -.wait_count FROM v$waitclassmetric_history h.************************************************* -.with no warranties.************************************************* SELECT Buffer Cache Hit Ratio Metric Name .stat_name.with no warranties.'hh24:mi:ss') "End".cc -. h. to_char(h. round(value. h. hh24:mi:ss ) Begin .wait_class_id .username.-.************************************************* -.Copyright © 2005 by Rampant TechPress -. to_char(h. -. to_char(end_time. -.value / 1000000).begin_time.contact info@rampant.time_waited. hh24:mi:ss ) End .2) Value FROM v$sysmetric_history WHERE Metric_name = Buffer Cache Hit Ratio ORDER BY Begin_time DESC. to_char(begin_time.************************************************* SELECT c.Copyright © 2005 by Rampant TechPress -.wait_class_id = h. -.To license this script for a commercial purpose.This script is free for non-commercial purposes -.sql -.sid = b.end_time. v$session b WHERE a.

PHYSICAL_READS FROM v$filemetric_history h.'hh24:mi:ss') "Begin". h.begin_time.AND c. m.AVERAGE_READ_TIME.value "current value".file_id AND f.begin_time DESC ---------- metric_values.wait_class = 'User I/O' ORDER BY h. m.file_name.end_time. Use at your own risk.contact info@rampant.This script is free for non-commercial purposes -.file_id = f.Copyright © 2005 by Rampant TechPress -.begin_time.file_id = 3 ORDER BY h. v$sysmetric_summary s WHERE m. m.value . --.sql -.************************************************* -.with no warranties.average)/s.************************************************* SELECT f.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.file_reads_hr_ash.average "average value".cc ************************************************* SELECT to_char(m.end_time.average > 0 AND ((m.metric_name.s. Use at your own risk. .average)*100 >= 10 AND lower(m.To license this script for a commercial purpose.metric_id = s.metric_name) NOT LIKE '%ratio%'.'hh24:mi:ss') "End". To license this script for a commercial purpose.metric_id AND s.'hh24:mi') "start time". -. s.metric_unit FROM v$sysmetric m. to_char(m. contact info@rampant. dba_data_files f WHERE h. to_char(h. h.'hh24:mi') "end time".cc -. to_char(h.begin_time DESC -.

s.To license this script for a commercial purpose.wait_class_id AND c. Use at your own risk. to_char(h.average_waiter_count. h.sql -.contact info@rampant.session_id AND (sm.0.cc -. -.wait_class. .wait_class = 'Application' .************************************************* SELECT c.This script is free for non-commercial purposes -.sid.with no warranties.'hh24:mi:ss') "Begin".time_waited.plug-in your metric name here ORDER BY h.This script is free for non-commercial purposes -.Copyright © 2005 by Rampant TechPress -.************************************************* -.-1) FROM v$sysmetric WHERE metric_name = 'cpu usage per sec') *100) > 1.with no warranties. -.To license this script for a commercial purpose.Copyright © 2005 by Rampant TechPress -.cpu/(SELECT decode(value. to_char(h. h.************************************************* -.wait_class_id = h.username FROM v$sessmetric sm.cpu_hot_sessions.end_time.contact info@rampant. --.wait_class "Wait Class".-.************************************************* select s.sid = sm. Use at your own risk.sql -. h.'hh24:mi:ss') "End". --. v$session s WHERE s. v$system_wait_class c WHERE c.begin_time. -.cc -.wait_count FROM v$waitclassmetric_history h.begin_time DESC.

'hh24:mi') "start time". n.contact info@rampant.average_write_time "average i/o time" FROM v$filemetric m.file_id = f.sql -.************************************************* SELECT to_char(m.'hh24:mi') "end time". m.wait_class <> 'Idle' -.file_id AND s.wait_count FROM v$eventmetric m.avg_io_time. m.name.To license this script for a commercial purpose. -.cc -.************************************************* SELECT to_char(m. m.-.end_time.event_id AND n.'hh24:mi') "start time".sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. v$event_name n WHERE m. m. -.Copyright © 2005 by Rampant TechPress -.event_id = n.This script is free for non-commercial purposes -.To license this script for a commercial purpose.begin_time. --.cc -.lstiotim > (m. Use at your own risk. to_char(m.lstiotim "last i/o time". Use at your own risk.************************************************* -.with no warranties. ------ metric_by_time.file# = f.average_write_time).average_read_time + m.num_sess_waiting.file_name.add your event metric name here AND m. -.contact info@rampant.time_waited > 0 ORDER BY 4 DESC.file_id AND s. --.sql -. f.This script is free for non-commercial purposes -.end_time. .average_read_time + m. s.************************************************* -. v$filestat s WHERE m.time_waited.with no warranties. dba_data_files f. to_char(m.begin_time.Copyright © 2005 by Rampant TechPress -. Use at your own risk.metric_by_time.'hh24:mi') "end time".

Use at your own risk.type. -.elapsedpercall "elapsed time".cc -.To license this script for a commercial purpose. to_char(m.contact info@rampant. m. -.sql -.************************************************* SELECT r.************************************************* -. r.impact_type.impact.benefit.with no warranties.cc ************************************************* select extract( day from snap_interval) *24*60+ extract( hour from snap_interval) *60+ extract( minute from snap_interval ) "Snapshot Interval".end_time DESC.service_name. -.'hh24:mi') "end time". r.'hh24:mi') "start time". f.contact info@rampant.end_time.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. f. extract( day from retention) *24*60+ extract( hour from retention) *60+ extract( minute from retention ) "Retention Interval" from dba_hist_wr_control.begin_time.dba_advisor_display. --. m. ---------- awr_settings.Copyright © 2005 by Rampant TechPress -. To license this script for a commercial purpose.--.cc -. f.************************************************* SELECT to_char(m.cpupercall "cpu time" FROM v$servicemetric_history m WHERE m. m. Use at your own risk. contact info@rampant.service_name = 'dbdabr' add your service name here ORDER BY m.Rank. .This script is free for non-commercial purposes -.To license this script for a commercial purpose.message FROM dba_advisor_recommendations r.

task_id ORDER BY r."STATS$UNDOSTAT" ("DBID". dbms_advisor. / ."_IDX$$_11A40002" ON "PERFSTAT".finding_id AND r. END.task_name = 'TASK_4502' AND r. dbms_advisor.1. DECLARE W_name VARCHAR2(100). To license this script for a commercial purpose.task_id = f. dbms_advisor.finding_id = f.mark_recommendation('SQL_ACC_TASK1'."STATS$DATABASE_INSTANCE_PK" */ /* RETAIN INDEX "PERFSTAT".dba_advisor_findings f WHERE r."SPV_BASELINES" ("AWR") COMPUTE STATISTICS."INSTANCE_NUMBER") COMPUTE STATISTICS. / ---------set set set set set dbms_advisor_mark.create_sqlwkld (W_name).SQLCODE begin dbms_advisor.'IMPLEMENTED')."_IDX$$_11A40001" ON "SPV". r."STATS$STATSPACK_PARAMETER_PK" */ whenever sqlerror EXIT SQL. dbms_advisor. CREATE INDEX "PERFSTAT". /* RETAIN INDEX "SPV".benefit DESC. BEGIN W_name := SQL_WRKLD_1 .cc ************************************************* feedback 1 linesize 80 trimspool on tab off pagesize 60 whenever sqlerror CONTINUE CREATE BITMAP INDEX "SPV". contact info@rampant.3.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.'IMPLEMENTED').4.2."SPV_ALERT_DEF_PK" */ /* RETAIN INDEX "PERFSTAT".mark_recommendation('SQL_ACC_TASK1'.'IMPLEMENTED').rank ASC.mark_recommendation('SQL_ACC_TASK1'. end.mark_recommendation('SQL_ACC_TASK1'. Use at your own risk.'IMPLEMENTED').

stat_name.snap_id = e.snap_id = b. contact info@rampant.dbid = &pDbId AND e.b1.instance_number = &pInstNum AND e.value > 0 ORDER BY 2 DESC from v$system_event where event like %wait% . Use at your own risk.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.stat_id = e1.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.dbid AND e1.-1) FROM dba_hist_sys_time_model e1 .instance_number = e.---------- sys_time_model_pct_db_time.instance_number AND e1.dbid = &pDbId AND b.dbid AND b1.snap_id AND b1. 100*(e.snap_id AND e1. Round(decode( e.dbid = e. contact info@rampant.value).b.value .value)/1000000. Use at your own risk.snap_id = &pEndSnap AND b.STAT_NAME" .stat_id = e.value) )/ (SELECT NVL((e1.instance_number = b.value . Round((e.stat_id AND e. dba_hist_sys_time_model b WHERE b.stat_id ).2) "Percent of Total DB Time" FROM dba_hist_sys_time_model e .snap_id = &pBgnSnap AND e.2)"Time (s)" .instance_number = &pInstNum AND b. dba_hist_sys_time_model b1 WHERE b1.stat_name = 'DB time' AND b1. To license this script for a commercial purpose. to_number(null) . ---------- display_cache_advice. To license this script for a commercial purpose.b.'DB time' .stat_name "E.cc ************************************************* .cc ************************************************* SELECT e.b.instance_number AND e1.dbid = b.value .value .

999 select to_char(begin_interval_time.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.999.999. col snap_time col value format a19 format 999.90 999. buffers_for_estimate c2.column column column column c1 c2 c3 c4 heading heading heading heading 'Cache Size (meg)' 'Buffers' 'Estd Phys Read Factor' 'Estd Phys Reads' format format format format 999. contact info@rampant.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. ---------- rpt_sysstat_10g. estd_physical_read_factor c3. accept stat_value number prompt 'Enter Statistics Threshold value: '. To license this script for a commercial purpose. value from dba_hist_sysstat natural join dba_hist_snapshot where .999.999 select size_for_estimate c1.999. estd_physical_reads c4 from v$db_cache_advice where name = 'DEFAULT' and block_size = (SELECT value FROM V$PARAMETER WHERE name = 'db_block_size') and advice_status = 'ON'. Use at your own risk.999 999.999. prompt set pages 999 break on snap_time skip 2 accept stat_name char prompt 'Enter Statistic Name: '.999 999.'yyyy-mm-dd hh24:mi') snap_time.

---------- hot_write_files_10g. phywrts from dba_hist_filestatxs natural join dba_hist_snapshot where phywrts > 0 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.'yyyy-mm-dd hh24:mi').'yyyy-mm-dd hh24:mi') . filename.999. To license this script for a commercial purpose.999 format a20 select to_char(begin_interval_time.cc ************************************************* 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. prompt set pages 999 break on snap_time skip 2 col filename col phywrts col snap_time format a40 format 999.'yyyy-mm-dd hh24:mi') snap_time. Use at your own risk. contact info@rampant. phywrts desc .stat_name = '&stat_name' and value > &stat_value order by to_char(begin_interval_time.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.

file_name.cc ************************************************* prompt prompt This will compare values from dba_hist_waitstat with prompt detail information from dba_hist_active_sess_history. 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.file_id = ash.snap_id and df.snap_id = ash. . wait_count. contact info@rampant.snap_id = snap.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.current_file# and obj. dba_hist_snapshot snap.current_obj# and wait_count > 50 order by to_char(begin_interval_time.snap_id and wait. Use at your own risk. -.999 select to_char(begin_interval_time. time from dba_hist_waitstat wait.999 999. object_name.. dba_data_files df. dba_objects obj where wait.'yyyy-mm-dd hh24:mi') snap_time.'yyyy-mm-dd hh24:mi'). file_name .object_id = ash. ---------- wait_time_detail_10g. dba_hist_active_sess_history ash. object_type. To license this script for a commercial purpose.

contact info@rampant.999 col c1 heading Object Name col c2 heading Option col c3 heading Index Usage Count select p. dba_hist_sqlstat s where p.cc ************************************************* format a30 format a15 format 999.999 .sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. p.3.object_name c1.object_owner <> 'SYS' and p.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.operation like and p.sql_id = s.options like '%RANGE SCAN%' and p. To license this script for a commercial purpose.cc ************************************************* col c0 heading Begin Interval time format a8 col c1 heading Table Name format a20 col c2 heading Disk Reads format 99.2.---------- awr_sql_index_freq.options c2. Use at your own risk. contact info@rampant.999. To license this script for a commercial purpose.object_name. p.sql_id group by p.options order by 1. %INDEX% ---------- awr_top_tables_phyrd. p. Use at your own risk.operation. count(1) c3 from dba_hist_sql_plan p.

dba_hist_sqlstat t. . ---------- awr_sql_object_freq.'mm-dd hh24') ORDER BY SUM(t.options c3.sql_id and t. DENSE_RANK() OVER (PARTITION BY to_char(s. p.operation c2.999 col col col col break on c1 skip 2 break on c2 skip 2 select p.disk_reads_total) desc) AS rnk from dba_hist_sql_plan p. sum(t. Use at your own risk.object_type like '%TABLE%' group by to_char(s.'mm-dd hh24').object_name c1. To license this script for a commercial purpose. dba_hist_snapshot s where p. sum(t.begin_interval_time.snap_id and p.cc ************************************************* c1 c2 c3 c4 heading heading heading heading Object Name Operation Option Object Count format format format format a30 a15 a15 999.999. p.disk_reads_total) c2.begin_interval_time. p. rnk ) where rnk <= 5 .'mm-dd hh24') c0.col c3 heading Rows Processed format 99.sql_id = t.snap_id = s.rows_processed_total) c3.999 select * from ( select to_char(s.object_name order by c0 desc.begin_interval_time.object_name c1.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. p. count(1) c4 from dba_hist_sql_plan p. contact info@rampant.

and then does so with a large multiblock read -.sql_id = s.v_$parameter where name = 'db_file_multiblock_read_count' / prompt @accept Table "Table to scan" SYS.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. set termout off alter session set events '10046 trace name context forever.sql -.table to scan.Purpose: find largest actual multiblock read size --. To license this script for a commercial purpose.dba_hist_sqlstat s where p.cc ************************************************* ---------------------------------------------------------------------.read actually performed.Copyright: (c) Ixora Pty Ltd -. p.SOURCE$ prompt Scanning . and with event 10046 enabled at level 8. p.options order by 1.Script: multiblock_read_test.operation..2.Author: Steve Adams --. contact info@rampant. ---------- multiblock_read_test..object_name.Description:This script prompts the user to enter the name of a -. / column value heading "Maximum possible multiblock read count" select value from sys.count. level 8' .object_owner <> 'SYS' and p.is then examined to find the largest multiblock -. --------------------------------------------------------------------@save_sqlplus_settings alter session set db_file_multiblock_read_count = 32768.sql_id group by p. The trace file -.3. Use at your own risk.

2. 4. Use at your own risk.'32K SUBCACHE'. 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. 7. bh.'DEFAULT'.blocks from x$kcbwds ds.obj . x$bh x where o./ select /*+ full(t) noparallel(t) nocache(t) */ count(*) from &Table t / alter session set events '10046 trace name context off' / set termout on @trace_file_name prompt prompt Maximum effective multiblock read count prompt ---------------------------------------host sed -n '/scattered/s/. 6.dataobj# = x.'8K SUBCACHE'.'4K SUBCACHE'.object_name. 'UNKNOWN') subcache. o.name object_name. 8.'RECYCLE'. bh.cc ************************************************* select decode( pd.'16K SUBCACHE'. 5. 3. x$kcbwbpd pd. 1.'KEEP'.'2K SUBCACHE'. contact info@rampant.bp_id. (select /*+ use_hash(x) */ set_ds.*p3=//p' &Trace_Name @restore_sqlplus_settings sort -n tail -1 ---------- display_multi_buffers. count(*) BLOCKS from obj$ o.

v_$filestat b.ts$ c.set_id >= pd.addr=bh.file# = d.name file_name.v_$datafile a. c. Use at your own risk.bp_size != 0 and ds.readtim.name tablespace_name.phyrds.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 .and x.phyrds desc.name) bh where ds. sys. sys.file# order by b.bp_lo_sid and ds.bp_hi_sid and pd. To license this script for a commercial purpose.writetim from sys.file# and e. ----- fileio8plus. b. ---------- fileio7.phywrts.state !=0 and o.phyblkwrt. b.o.owner# !=0 group by set_ds.file# = b.v_$dbfile d. b.set_id <= pd.set_ds.ts# = c.file# and a. b. sys.ts# and e.phyblkrd. contact info@rampant. sys.file$ e where a.file# = d. b. b.cc ************************************************* select d.

file# = b.readtim. sys.file# = d. sys.ktfthctsn = c.ts# = c.readtim.phywrts.writetim from sys.ktfthctsn = c.file# union all select v.file# and a.cc ************************************************* select d. b.fntyp = 7 and v.ktfthctfno and hc.phyblkwrt.v_$dbfile d.ts$ c. b.phyblkrd.name tablespace_name. b.phyblkwrt.ts$ c.ts# and v.v_$filestat b.ts# and e.v_$datafile a.name file_name.phyrds. b.ktfthctfno and hc.fnnam file_name.fnnam is not null and v.phywrts.v_$tempstat b. b.file# = d. c. b.x$ktfthc hc where a. b. b. contact info@rampant. sys. b.writetim from sys. sys.file$ e where a.file# = b.ts# . sys. b. sys.fnfno = hc. sys. To license this script for a commercial purpose.file# and e.x$kccfn v. sys.------ with no warranties.v_$tempfile a.phyrds. c.file# and a.file# = hc. b. Use at your own risk. b.name tablespace_name.phyblkrd.

'physical reads direct'.order by 3 desc. 0)) sum (decode (name. 'physical writes'. 'consistent gets'.v_$sysstat where name in ('consistent changes'. ---------- globiostats.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. 'db block changes'. Use at your own risk. . 'physical reads direct (lob)'. 0)) sum (decode (name. 'user commits'. contact info@rampant. value.cc ************************************************* select name.cc ************************************************* select 100 100 * (round ((sum (decode (name. ---------- buffratio. 'sorts (disk)'. To license this script for a commercial purpose. value. 'db block gets'. 'user rollbacks' ) order by 1. To license this script for a commercial purpose. Use at your own risk.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. 'physical reads'. contact info@rampant. 'physical reads'. value from sys.

0) sum_io2 from sys. 'physical reads direct').value.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. 0))) / (sum (decode (name. rem @title132 'File I/O Statistics Report' spool rep_out\&db\fileio&&today . set feedback off verify off lines 132 pages 60 sqlbl on trims on rem select nvl(sum(a.v_$filestat a.v_$tempstat b.99 heading 'Block Read Ratio' column bwratio format 999.phywrts). select &st1+&st2 sum_io from dual. 'session logical reads'. 1)) ).'ddmonyyyyhh24miss') dt from dual. 'physical reads'.cc ************************************************* rem rem NAME: fileio.v_$sysstat where name in ('session logical reads'.phyrds+b.sql rem rem FUNCTION: Reports on the file io status of all of the rem FUNCTION: datafiles in the database.0) sum_io1 from sys.3)) hit_ratio from sys. 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. To license this script for a commercial purpose. contact info@rampant.phyrds+a.999 heading 'Percent Of IO' column brratio format 999. ---------- fileio. Use at your own risk.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 a45 heading 'File Name' column file# format 9999 heading 'File' column dt new_value today noprint select to_char(sysdate.phywrts). select nvl(sum(b. 'physical reads direct (lob)'. value.

a.phyrds+a.phyrds+c.0) sum_io1.phyrds+a. c. elapsed_seconds number.v_$dbfile b where a.phyblkwrt/greatest(c. c.1)) bwratio from sys.phywrts.v_$tempfile d where c.file#.phywrts. sum_io1 number.1)) bwratio from sys. (100*(a. (a.file#.phywrts)/&divide_by) Percent. tot_io_per_sec number. sum_io22 number.phyblkrd. c.phywrts). contact info@rampant. sys. tot_io number.v_$tempstat c. sum_io2 number.0) sum_io2 from sys. (100*(c. sys.phywrts.name.phyblkwrt/greatest(a. a.gv_$tempstat b. nvl(sum(b.cc ************************************************* set serveroutput on declare cursor get_io is select nvl(sum(a. (c.phyblkrd/greatest(a. fixed_io_per_sec number.phyrds+b.phyrds. (a.phyrds. Use at your own risk. c.file# union select c.phywrts.(c.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.phyrds.gv_$filestat a union select to_number(null) sum_io1.phyblkwrt.phyblkrd/greatest(c.to_number(null) sum_io2 from sys.1)) brratio.1)) brratio.b.v_$filestat a. sum_io12 number.phyblkrd.d.phyblkwrt. now date. a.phyrds.phywrts)/&divide_by) Percent.name. . a. To license this script for a commercial purpose.file# order by 1 / spool off pause Press enter to continue set feedback on verify on lines 80 pages 22 clear columns ttitle off ---------- get_io.file#=b.select a.file#=d.phywrts).

temp_io_per_sec:=sum_io22/elapsed_seconds. '9.990 heading 'Percent Of Non-Idle Waits' duration new_value millisec noprint p_of_total heading 'Percent of Total Uptime' format 999.999.9999 set lines 132 feedback off verify off pages 50 select to_number(sysdate-startup_time)*86400*1000 duration from v$instance.999 heading 'Average Waits' time_waited format 999.999. select sysdate into now from dual. select sum_io12+sum_io22 into tot_io from dual. Use at your own risk.put_line('Temp IO/SEC :' to_char(temp_io_per_sec. dbms_output.99')). dbms_output. else sum_io22:=sum_io2. 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%' .sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. end. for i in 1. select ceil((now-max(startup_time))*(60*60*24)) into elapsed_seconds from gv$ins tance.. contact info@rampant.99')). '9.99')).999.999 heading 'Total Waits' average_wait format 999.2 loop fetch get_io into sum_io1. tot_io_per_sec:=tot_io/elapsed_seconds. if i = 1 then sum_io12:=sum_io1.999.put_line('Fixed IO/SEC:' to_char(fixed_io_per_sec.put_line('Total IO/SEC:' to_char(tot_io_Per_Sec.temp_io_per_sec number. '9. end loop.999.put_line('Elapsed Sec :' to_char(elapsed_seconds. / ---------col col col col col col col col col wait_report. sum_io2.999. end if. begin open get_io.999. dbms_output.999.cc ************************************************* event format a30 heading 'Event Name' waits format 999.999.'9.999 heading 'Time Waited' total_time new_value divide_by noprint value new_value val noprint percent format 999.999. dbms_output. To license this script for a commercial purpose.999.99')). fixed_io_per_sec:=sum_io12/elapsed_seconds.

'virtual cir cuit status'.'dispatcher timer') and time_waited>0 order by percent desc / spool off clear columns ttitle off clear computes clear breaks ---------- toptables. @title132 'System Events Percent' break on report compute sum of time_waited on report spool rep_out/&db/sys_events select name event. To license this script for a commercial purpose. 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'. time_waited/(&&divide_by+&&val)*100 Percent. time_waited. time_waited/(total_waits-total_timeouts) average_wait. contact info@rampant.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. value/(&&divide_by+&&val)*100 Percent. 0 average_wait. 0 waits.'virtual cir cuit status'. value/&&millisec*100 p_of_total from v$sysstat where name ='CPU used when call started' union select event.'ges remote message'.cc ************************************************* . select value from v$sysstat where name ='CPU used when call started'. value time_waited.'ges remote message'. Use at your own risk.'dispatcher timer') .and event not like 'PX%' and event not like 'sbt%' and event not in ('gcs remote message'. total_waits-total_timeouts waits.

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

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

1)). 'SQL*Net more data from client'. 'pmon timer'.2) pct_waits. 'virtual circuit status'. 'PL/SQL lock timer'. 'rdbms ipc reply'. (select sum(total_waits) sum_waits. 'SQL*Net break/reset to client'. 'pipe get'. 'SQL*Net message from client'. 'dispatcher timer'. time_wait_sec. round((time_waited / 100). total_timeouts. 'WMON goes to sleep'. 'rdbms ipc message'. round((average_wait / 100). round(100 * (time_wait_sec / greatest(sum_time_waited. 'parallel query idle wait . total_waits. 'Queue Monitor Wait'. average_wait_sec from (select event. 'slave wait'. 'jobq slave wait'.2) average_wait_sec from sys. 'Null event'.round(100 * (total_waits / sum_waits).2) pct_time_waited. 'parallel query dequeue wait'. 'SQL*Net break/reset to client'. 'dispatcher timer'.1)). 'SQL*Net message from client'. 'smon timer'. 'SQL*Net message to client'. total_timeouts. 'smon timer'. 'SQL*Net message to client'. round(100 * (total_timeouts / greatest(sum_timeouts.v_$system_event where event not in ('lock element cleanup'. 'parallel query idle wait .Slaves'. 'PL/SQL lock timer'. 'PX Idle Wait') AND event not like 'DFS%' AND event not like 'KXFX%'). 'wakeup time manager'. sum(total_timeouts) sum_timeouts. sum(round((time_waited / 100). 'rdbms ipc message'. 'SQL*Net more data from client'.2) time_wait_sec. 'rdbms ipc reply'.Slaves'. 'pmon timer'.v_$system_event where event not in ('lock element cleanup'.2) pct_timeouts. 'parallel query dequeue wait'.2)) sum_time_waited from sys. 'pipe get'. . 'Null event'.

v_$statname c.cc ************************************************* select sid.v_$bgprocess p where a. sys. sys. nvl(b. (select sum(value) total_io from sys.paddr and b. 'physical writes'. 'physical writes direct'.sid=a. contact info@rampant.v_$sesstat a. . sys. sum(value) total_user_io from sys. 'PX Idle Wait') AND event not like 'DFS%' AND event not like 'KXFX%') order by 4 desc.p. 1 asc.2) tot_io_pct from (select b. username.name in ('physical reads'.name) username.username. Use at your own risk. 'physical writes direct (lob)'.paddr (+) = b. To license this script for a commercial purpose.sid.name in ('physical reads'.username. 'Queue Monitor Wait'.statistic#=c.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. round(100 * total_user_io/total_io.v_$sesstat a where a.statistic# and p. 'physical writes'. 'wakeup time manager'.sid and c.'slave wait'.statistic# and c.v_$statname c.statistic#=c. ---------- physpctio. 'physical reads direct (lob)') group by b. 'physical writes direct'.v_$session b.sid sid. 'jobq slave wait'.name)).p. 'physical reads direct'. 'WMON goes to sleep'. nvl(b. sys. 'virtual circuit status'.

'consistent gets'.NAME) USERNAME. SUM(VALUE) TOTAL_USER_IO FROM sys.STATISTIC#=c. 'physical writes direct'.USERNAME. 'db block changes'.NAME in ('physical reads'.NAME in ('physical reads'.2) TOT_IO_PCT SELECT FROM (SELECT b. (select sum(value) TOTAL_IO from sys.V_$STATNAME c.SID and c. 'db block gets'.'db block gets'.paddr and b.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.STATISTIC# and c. sys. 'physical writes direct (lob)'.'physical writes'. USERNAME. 'physical reads direct (lob)') GROUP BY b. To license this script for a commercial purpose. 'physical reads direct (lob)')) order by 3 desc. 'consistent changes'. 'physical reads direct'.STATISTIC#=c. contact info@rampant. ROUND(100 * TOTAL_USER_IO/TOTAL_IO.V_$STATNAME c.V_$SESSTAT a.SID.SID SID.V_$SESSTAT a WHERE a.SID=a. nvl(b.name)).p. sys. ---------- totpctio. Use at your own risk.cc ************************************************* SID. 'physical reads direct'.USERNAME. 'physical writes direct'.V_$SESSION b. 'physical writes direct (lob)'.'db block changes'. sys. 'physical writes direct (lob)'. . nvl(b. 'consistent gets'.STATISTIC# and p.'physical reads direct'.paddr (+) = b.'physical writes'.p. 'consistent changes'.v_$bgprocess p WHERE a. sys.

sum(decode(c.name.3)) hit_ratio.b.name.name.'user commits'. 0)) sum (decode (c. 'physical reads direct (lob)'.0)) disk_sorts. 'physical reads direct'. Use at your own risk.'sorts (rows)'.name.username) user_name. 0))).name. 'physical reads direct'.0)) ) total_logical_io.cc ************************************************* select b. value.sid sid. 100 100 *(round ((sum (decode (c.e.0)) memory_sorts. 'physical writes direct'.value. sum(decode(c.username.0))) total_physical_io. 'db block gets'. .value.name. 'db block changes'.'sorts (disk)'.0)) + sum(decode(c.name.'db block gets'.0)) + sum(decode(c.value. d.value.name.'physical reads direct (lob)')) ORDER BY 3 DESC. 'physical reads'.name.0)) + sum(decode(c. To license this script for a commercial purpose.value.'consistent gets'.name.0)) + sum(decode(c.value.0)) + sum(decode(c. (sum(decode(c.name.'consistent changes'.name.value. 1)) + sum (decode (c. ---------- topiousers.0)) rows_sorted. value. decode (b.0)) commits. sum(decode(c.name.name.name.machine machine_name.name.'physical writes'.name. 'consistent gets'.spid os_id. value.value. (sum(decode(c. b.null.value.0)) + sum(decode(c. contact info@rampant.'mm/dd/yy hh:mi:ss pm') logon_time. value.value. 'physical writes direct (lob)'.value.name. to_char(logon_time.value.'sorts (memory)'.0)) + sum(decode(c.value.0)) + sum(decode(c.value.name. 0))) / (sum (decode (c.'physical reads'.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. sum(decode(c.

name.name in ('physical reads'. 'physical writes'.value. sum(decode(c.b. sum(decode(c. 'physical writes direct'. 'consistent changes'. sys.0)) executions. 'sorts (memory)'.sid and d.paddr and c.name.value.addr = b. sum(decode(c. 'execute count' ) group by b.value. 'physical reads direct (lob)'.v_$session b.syswaits.paddr (+) = b.name.0)) consistent_changes from sys. 'physical writes direct (lob)'. sys.************************************************* -. decode (b. sys. 'db block changes'. 'consistent gets'. 'sorts (disk)'.sql -.'consistent changes'. 'physical reads direct'.spid.0)) db_block_gets. 'db block gets'. 'user rollbacks'. to_char(logon_time.0)) consistent_gets.statistic# and b.name.name. 'sorts (rows)'.v_$sesstat a.'user rollbacks'.Copyright © 2005 by Rampant TechPress .machine.v_$process d.0)) rollbacks.'physical reads'.name.'consistent gets'.value. sum(decode(c. b.username).paddr and e.'db block gets'.e.v_$bgprocess e where a. 'user commits'.sid=a.v_$statname c. d.null. sum(decode(c.value.name.value. -.'mm/dd/yy hh:mi:ss pm') order by 6 desc.sid. sys.username.statistic#=c.0)) physical_reads.sum(decode(c.'execute count'.

'SQL*Net more data to client '. sum(round((time_waited / 100).2) pct_tot_waits.cc ************************************************* event. avg_wait_sec select from (select event. 'pmon timer '. 'virtual circuit status '.2) pct_secs_waits. 'WMON goes to sleep') and event not like 'DFS%' and event not like 'KXFX%'). total_timeouts. 'rdbms ipc message '. time_wait_sec.v_$system_event where event not in ('lock element cleanup '. total_timeouts. 'SQL*Net more data to client '.2) avg_wait_sec from sys. 'pmon timer '. round(100 * (total_waits / sum_waits). 'SQL*Net message from client '.------- This script is free for non-commercial purposes with no warranties. 'SQL*Net break/reset to client '. 'parallel query idle wait . 'SQL*Net message to client '. Use at your own risk. 'slave wait '. 'PL/SQL lock timer '.2) time_wait_sec. 'smon timer '. 'smon timer '. 'pipe get '. To license this script for a commercial purpose. round((time_waited / 100). round(100 * (time_wait_sec / sum_secs).Slaves '. contact info@rampant.2)) sum_secs from sys. 'SQL*Net message to client '. round((average_wait / 100).v_$system_event where event not in ('lock element cleanup '. (select sum(total_waits) sum_waits. 'rdbms ipc message '. total_waits. 'dispatcher timer '. 'SQL*Net message from client '. 'parallel query dequeue wait '. 'Null event '. 'SQL*Net break/reset to client '. total_waits. .

filename.average_wait a. c3.total_waits + b. 'WMON goes to sleep') and event not like 'DFS%' and event not like 'KXFX%') order by 2 desc.total_waits) b.'dispatcher timer '. Use at your own risk. 'parallel query dequeue wait '.999.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. 'PL/SQL lock timer '. 'Null event '.cc ************************************************* c1 c2 c3 c4 c5 heading heading heading heading heading 'Average Waits forFull Scan Read I/O' 'Average Waits for Index Read I/O' 'Percent of I/O Waits for Full Scans' 'Percent of I/O Waits for Index Scans' 'Starting Value for optimizer index cost adj' format format format format format 9999. 'pipe get '.999 9999.sql break on begin_interval_time skip 2 column phyrds format 999.total_waits /(a. 'virtual circuit status '.average_wait b. ? phys_reads. v$system_event b where a.Slaves '.total_waits + b.event = 'db file scattered read' and b.99 999 select a.average_wait)*100 from v$system_event a. c4. c1. c2.average_wait / a.event = 'db file sequential read' .999 9. 'slave wait '. contact info@rampant.total_waits) (b.total_waits /(a.99 9. 'parallel query idle wait .999 column begin_interval_time format a25 select begin_interval_time. To license this script for a commercial purpose. c5 . ---------col col col col col sum_read_waits.

'yyyy-mm-dd hh24:mi') snap_time. To license this script for a commercial purpose. ---------- hot_write_files. Use at your own risk. . prompt set pages 999 break on snap_time skip 2 col filename col phywrts col snap_time format a40 format 999.phyrds from dba_hist_filestatxs natural join dba_hist_snapshot .999 format a20 select to_char(begin_interval_time. contact info@rampant.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.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. filename. phywrts from dba_hist_filestatxs natural join dba_hist_snapshot where phywrts > 0 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.'yyyy-mm-dd hh24:mi').

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. 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.0) sum_io2 from dba_hist_tempstatxs b where snap_id=&&snap. (100*(a.phyblkwrt. a.phywrts). rem @title132 'Snap&&snap File I/O Statistics Report' spool rep_out\&db\fileio&&snap select a.phyblkrd.phyrds+b. (a.phyblkrd/greatest(a.999 heading 'Percent Of IO' brratio format 999.phywrts.0) sum_io1 from dba_hist_filestatxs a where snap_id=&&snap.phyrds+a.phyrds+a.phywrts). a.1)) brratio.phyblkwrt/greatest(a.1)) bwratio from .cc ************************************************* rem rem NAME: snapfileio. select nvl(sum(b.99 heading 'Block Read Ratio' bwratio format 999.filename. (a. ---------- snapfileio_10g. Use at your own risk.phyrds.phyrds. a. contact info@rampant.sql rem FUNCTION: Reports on the file io status of all of the rem FUNCTION: datafiles in the database for a single snapshot. select &st1+&st2 sum_io from dual. a.phywrts)/&divide_by) Percent.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.phywrts desc .phywrts.

phyblkwrt. c.1)) brratio.phywrts.phyblkrd/greatest(c.(c.phywrts)/&divide_by) Percent.phywrts. c.dba_hist_filestatxs a where a.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 ---------rem rem rem rem rem rem rem rem rem rem snapdeltafileio_awr.phyrds+c.sql FUNCTION: Reports on the file io status of all of FUNCTION: the datafiles in the database across FUNCTION: two snapshots.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.snap_id=&&snap union select c.cc ************************************************* NAME: snapdeltafileio.1)) bwratio from dba_hist_tempstatxs c where c.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 . contact info@rampant.phyrds.999 heading 'Percent Of IO' column brratio format 999.phyblkwrt/greatest(c. HISTORY: WHO WHAT WHEN Mike Ault Created 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. (c.filename.phyblkrd. c. Use at your own risk.99 heading 'Block Read Ratio' column bwratio format 999. To license this script for a commercial purpose.phyrds. c. (100*(c.

phyrds-a. (100*((b.1)) bwratio from dba_hist_filestatxs a.filename union select c.phyrds)+(b. select &st1+&st2 sum_io from dual.filename=b.phywrts-c. dba_hist_filestatxs b where a. ((d.phyblkwrt phyblgwrt. d.phyrds-a.phywrts-c.0) sum_io1 from dba_hist_filestatxs a. d.phywrts).phyblkwrt-c.filename. select nvl(sum((b.1)) brratio.phyrds-c.phywrts))/&divide_by) Percent.phywrts-a. ((d.phywrts-a. b.phyrds).phyrds)+(d.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 .filename. (100*((d. ((b.filename=b.1)) brratio.filename.phyblkrd phyblkrd.phyblkrd-c.phyblkwrt)/greatest((d. d. dba_hist_tempstatxs d where c.phyrds-a.phyrds -a.filename. ((b.phyblkwrt phyblgwrt.phywrts-c.phywrts)).phywrts))/&divide_by) Percent. b.snap_id=&&sec_snap_id and a.phyblkrd-a.snap_id=&&first_snap_id and b.phyrds phyrds. b.filename=d.phywrts phywrts.snap_id=&&first_snap_id and b.select nvl(sum((b.phyrds-a.phywrts-a.snap_id=&&first_snap_id and d.snap_id=&&sec_snap_id and a.phyrds phyrds.phywrts).phyblkrd)/greatest((b.a.filename=b.phyrds-c.phywrts)).phyblkwrt)/greatest((b. b.phyblkwrt-a. dba_hist_tempstatxs b where a.1)) bwratio from dba_hist_tempstatxs c.phywrts-a.0) sum_io2 from dba_hist_tempstatxs a.phyblkrd)/greatest((d. dba_hist_filestatxs b where a. d.phywrts phywrts.phyblkrd-c.phyrds-c. 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.phywrts-a.phyrds)+(b.phyblkwrt-a.snap_id=&&first_snap_id and b.phyrds)+(b.phyrds).snap_id=&&sec_snap_id and a.phyblkrd.phyblkrd phyblkrd.snap_id=&&sec_snap_id and c.phyblkwrt-c.

'Sunday') snap_time. Use at your own risk.'Friday '.2.7.'Wednesday'.'Saturday'. Use at your own risk.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.cc ************************************************* prompt Copyright 2004 by Donald K.'Tuesday'.---------- rpt_10g_sysstat_dy.'d') snap_time1.6. ---------- ash_obj_waits.5. To license this script for a commercial purpose.999 select decode(snap_time1.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.'d') ) . contact info@rampant.'d') order by to_char(begin_interval_time.1. To license this script for a commercial purpose.'Monday'. col snap_time col avg_value format a19 format 999. contact info@rampant. avg_value from ( select to_char(begin_interval_time.4.cc ************************************************* .'Thursday'.999.3. Burleson 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 = 'physical reads' group by to_char(begin_interval_time.

consistent_gets)+ (new.event order by 4 desc.cc ************************************************* column bhr format 9.event. new. dba_objects obj where ash. sum(ash.db_block_gets-old.consistent_gets)+ (new. obj.name and new.consistent_gets)+ (new.db_block_gets-old. ---------- rpt_bhr_all. contact info@rampant.name = old.consistent_gets-old. Use at your own risk. obj.db_block_gets-old.db_block_gets-old. ash.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.db_block_gets)) < .object_name.current_obj# = obj.sample_time > sysdate -1 and ash.consistent_gets-old.select obj.snap_id = sn.time_waited) wait_time from v$active_session_history ash.physical_reads-old.db_block_gets)) bhr from dba_hist_buffer_pool_stat old.name buffer_pool_name. ash.'yyyy-mm-dd HH24') mydate.physical_reads)) / ((new.consistent_gets-old.physical_reads)) / ((new.object_type.physical_reads-old.99 column mydate heading 'yr.db_block_gets))(new.object_name.' select to_char(snap_time.wait_time + ash. mo dy Hr. dba_hist_sgasn where (((new.snap_id and . To license this script for a commercial purpose.object_type.consistent_gets)+ (new.90 and new.consistent_gets-old. dba_hist_buffer_pool_statnew.db_block_gets))(new. (((new.object_id group by obj.

column column column column logical_reads format 999.snap_id = sn.stats$snapshot sn where a.statistic# = 39 . perfstat.snap_id and e.value-f. Use at your own risk.999. perfstat. round(100 * (((a.v value))) "BUFFER HIT RATIO" from perfstat.snap_id-1 .snap_id = sn.'yyyy-mm-dd HH24'). perfstat.stats$sysstat e.snap_id-1 and f.snap_id = sn.snap_id = sn.value-f.cc ************************************************* set pages 9999.stats$sysstat d.value "phys_reads".stats$sysstat g.snap_id-1 and a.snap_id and d. contact info@rampant.stats$sysstat a.snap_id and b. ---------- rpt_bhr_oracle8.stats$sysstat b.999 phys_writes format 999.snap_id = sn.snap_id = sn.value + b.statistic# = 39 and e.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. a.snap_id-1 and g.value)) / (a.stats$sysstat f.999.value-e.999.value-g. perfstat.snap_id = sn.999 "BUFFER HIT RATIO" format 999 select to_char(snap_time.value "phys_writes". d.snap_id = sn.value))-(c.snap_id and c.value)+(b. c.value)+(b.value-e. perfstat. perfstat.old.stats$sysstat c.value "logical_reads". perfstat.999 phys_reads format 999. To license this script for a commercial purpose.

consistent_gets-old. contact info@rampant.name and new.db_block_gets-old.statistic# = 41 .name buffer_pool_name.db_block_gets))(new.' select to_char(end_interval_time. . (((new.statistic# = 40 and g. mo dy Hr.physical_reads-old.and b.'yyyy-mm-dd HH24') mydate.db_block_gets)) < .db_block_gets)) bhr from dba_hist_buffer_pool_stat old.db_block_gets))(new.statistic# = 38 and c.db_block_gets-old.cc ************************************************* column bhr format 9.90 and new.consistent_gets)+ (new. dba_hist_buffer_pool_stat new.physical_reads-old. ---------- rpt_bhr_all_awr.snap_id = sn.consistent_gets)+ (new.snap_id and old.snap_id-1 . To license this script for a commercial purpose.99 column mydate heading 'yr. new.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.db_block_gets-old. dba_hist_snapshot sn where (((new.consistent_gets-old. Use at your own risk.statistic# = 40 and d.physical_reads)) / ((new.consistent_gets)+ (new.snap_id = sn.consistent_gets)+ (new.name = old.db_block_gets-old.statistic# = 38 and f.physical_reads)) / ((new.consistent_gets-old.consistent_gets-old.

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

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

snap_id-1 and old.pins-old.reloads)/ sum(new.99999 break on mydate skip 2. sum(new.contact info@rampant.'yyyy-mm-dd HH24') mydate. create table t1 as select o.'yyyy-mm-dd HH24').namespace group by to_char(snap_time. .subobject_name subobject_name. stats$snapshot sn where new.cc ************************************************* set pages 999 set lines 92 ttitle 'Contents of Data Buffers' drop table t1. o. o. column column column column mydate c1 c2 c3 heading heading heading heading 'Yr. Use at your own risk. select to_char(snap_time.999 "Library Cache Miss Ratio" format 999. stats$librarycache new.cc -.pins) library_cache_miss_ratio from stats$librarycache old.snap_id = sn.reloads-old.snap_id and old.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.snap_id = new.owner owner.999.pins-old. sum(new.namespace = new.--. To license this script for a commercial purpose.' format a16 "execs" format 9. -. ---------- buf_blocks.reloads) c2. set pages 999.reloads-old.999 "Cache Misses While Executing" format 9. Mo Dy Hr. contact info@rampant.object_name object_name.************************************************* set lines 80.To license this script for a commercial purpose.999. sum(new.pins) c1.

o.object_type order by count(distinct file# block#) desc . sum(bytes)/sum(blocks) c6 from t1. . column column column column column column column c0 c1 c2 c3 c4 c5 c6 heading heading heading heading heading heading heading num_blocks "Owner" format a12 "Object Name" format a30 "Object Type" format a8 "Number of Blocks in Buffer Cache" format 99. buffer_pool c5. object_name.subobject_name.segment_type = t1. object_name c1.'-') group by t1. object_type.001))*100 c4. (sum(num_blocks)/greatest(sum(blocks).partition_name.999 "Percentage of object blocks in Buffer" format 999 "Buffer Pool" format a7 "Block Size" format 99. buffer_pool having sum(num_blocks) > 10 order by sum(num_blocks) desc .'-') = nvl(t1.object_type and nvl(s.status != 'free' group by o.owner. v$bh bh where o. count(distinct file# block#) from dba_objects o.objd and o. o. o.segment_name = t1. case when object_type = 'TABLE PARTITION' then 'TAB PART' when object_type = 'INDEX PARTITION' then 'IDX PART' else object_type end c2.owner. sum(num_blocks) c3. dba_segments s where s.owner not in ('SYS'.object_name.owner c0.999.object_name and s.owner = t1.owner and s.999 select t1.'SYSTEM') and bh.data_object_id = bh. .object_type object_type.subobject_name.o.

---------- all_vbh_status. count(*) as num from v$bh where file# in( select file_id from dba_data_files where tablespace_name in ( select tablespace_name from dba_tablespaces where block_size=32768)) group by '32k ' status union select '16k ' status as status. Use at your own risk.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. count(*) as num from v$bh where file# in( select file_id from dba_data_files where tablespace_name in ( select tablespace_name from dba_tablespaces where block_size=8192)) group by '8k ' status union . To license this script for a commercial purpose. count(*) as num from v$bh where file# in( select file_id from dba_data_files where tablespace_name in ( select tablespace_name from dba_tablespaces where block_size=16384)) group by '16k ' status union select '8k ' status as status. contact info@rampant.cc ************************************************* set pages 50 @title80 'All Buffers Status' spool rep_out\&&db\all_vbh_status select '32k ' status as status.

Use at your own risk. To license this script for a commercial purpose. count(*) as num from v$bh where file# in( select file_id from dba_data_files where tablespace_name in ( select tablespace_name from dba_tablespaces where block_size=4096)) group by '4k ' status union select '2k ' status as status.com col "Object" format a20 set numwidth 12 set lines 132 . count(*) as num from v$bh where file# in( select file_id from dba_data_files where tablespace_name in ( select tablespace_name from dba_tablespaces where block_size=2048)) group by '2k ' status union select status.cc ************************************************* Crosstab of object and statistic for an owner by Mike Ault www.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.select '4k ' status as status. contact info@rampant. count(*) as num from v$bh where status='free' group by status order by 1 / spool off ttitle off ------------ obj_xtab.oracle-script.

'All Objects'. ORACLE_SID=$1 .statistic_name = 'logical reads' then a.set pages 50 @title132 'Object Wait Statistics' spool rep_out\&&db\obj_stat_xtab select * from ( select DECODE (GROUPING(a. we must set the environment .statistic_name = 'ITL waits' then a. 1. sum(case when a.object_name)) b where (b. sum(case when a."ITL Waits">0 or b.statistic_name = 'buffer busy waits' then a. .value else null end) "Logical Reads" from v$segment_statistics a where a.cc ************************************************* #!/bin/ksh # First."Buffer Busy Waits">0) / spool off clear columns ttitle off ---------- avoid_high_invalidations.value else null end) "Row Lock Waits".statistic_name = 'physical reads' then a. To license this script for a commercial purpose.object_name). a. Use at your own risk.value else null end) "Physical Reads".value else null end) "ITL Waits". contact info@rampant.ksh ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.owner like upper('&owner') group by rollup(a. sum(case when a.value else null end) "Buffer Busy Waits". sum(case when a. .object_name) AS "Object".statistic_name = 'row lock waits' then a. . sum(case when a.

sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. . # ********************************************************* nohup purge_job.owner owner. o. To license this script for a commercial purpose. Use at your own risk. create table t1 as select o.export ORACLE_SID ORACLE_HOME=`cat /etc/oratab grep ^$ORACLE_SID: cut -f2 -d':'` #ORACLE_HOME=`cat /var/opt/oracle/oratab grep ^$ORACLE_SID: cut -f2 -d':'` export ORACLE_HOME PATH=$ORACLE_HOME/bin:$PATH export PATH # # # # # # ********************************************************* This will reduce the size of the data buffer immediately preceding a large truncate or data purge ********************************************************* $ORACLE_HOME/bin/sqlplus s /nologin<<! connect system/manager as sysdba.subobject_name subobject_name. alter system set db_cache_size=1500m. exit ! ---------- buf_keep_pool. contact info@rampant.object_name object_name. exit ! # ********************************************************* # Now we can invoke the specialty task.cc ************************************************* set pages 999 set lines 92 spool keep_syn.lst drop table t1. alter system set db_cache_size=10m.ksh > /tmp/purge. alter system flush buffer_cache.lst 2>&1 & $ORACLE_HOME/bin/sqlplus s /nologin<<! connect system/manager as sysdba. o.

object_type object_type.subobject_name.' from t1.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.partition_name.owner '. To license this script for a commercial purpose.status != 'free' group by o. v$bh bh where o.owner. --------- hot_buffers.data_object_id = bh.'SYSTEM') and bh.subobject_name.segment_type ' ' t1.o.owner not in ('SYS'. dba_segments s where s. t1.object_name.001))*100 > 80 . o. num_blocks select 'alter ' s.' s. contact info@rampant.object_name and s.cc .segment_type = t1.owner.'INDEX') group by s. o. Use at your own risk. spool off.segment_name = t1.'-') and buffer_pool <> 'KEEP' and object_type in ('TABLE'.segment_type.object_type and nvl(s. s. count(distinct file# block#) from dba_objects o.owner = t1.owner and s. o.segment_name having (sum(num_blocks)/greatest(sum(blocks). .segment_name ' storage (buff er_pool keep).'-') = nvl(t1.objd and o.object_type order by count(distinct file# block#) desc .

To license this script for a commercial purpose. set lines 80.x$bh a.cc ************************************************* select 'alter table ' p.object_name = s. COUNT(1) buffers.************************************************* -.object_id and b. blocks.name ' storage (buffer_pool keep). Use at your own risk.' p.999 SELECT object_type mytype. object_type. dba_hist_sqlstat a.' from dba_tables t. object_name myname. (select distinct .obj = b.-.owner not in ('SYS'. blocks. contact info@rampant.'SYSTEM') GROUP BY object_name. ---------- get_keep_pool. dba_segments s. dba_segments s WHERE a. obj HAVING AVG(tch) > 5 AND COUNT(1) > 20.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. set pages 999. AVG(tch) avg_touches FROM sys.segment_name and b. dba_objects b. column column column column avg_touches format 999 myname heading 'Name' format a30 mytype heading 'Type' format a10 buffers format 999.You MUST connect as SYS to run this script connect sys/manager.owner '.

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

blocks ) ---------- keep_syn.owner not in ('SYS'. contact info@rampant.num_rows.table_name = s.owner = p.object_type object_type. o. create table t1 as select o.buffer_pool <> 'KEEP' having s. o.owner not in ('SYS'.name and t.owner owner. To license this script for a commercial purpose.name.'SYSTEM') and t.owner. v$bh bh where o. s.blocks < 50 group by p.segment_name and t.lst drop table t1. Use at your own risk.subobject_name subobject_name.subobject_name.object_name.object_type order by count(distinct file# block#) desc num_blocks .status != 'free' group by o. o.table_name = p.owner and t.owner. o.data_object_id = bh.objd and o. t.and t.object_name object_name.'SYSTEM') and bh. o. p. count(distinct file# block#) from dba_objects o.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. o.cc ************************************************* set pages 999 set lines 92 spool keep_syn.

s. t1.segment_type = t1.*********************************************************** select 'alter table ' p.segment_name having (sum(num_blocks)/greatest(sum(blocks).sql -.owner and s.' p. v$sqlarea a.' from dba_tables t.owner '. contact info@rampant.segment_type ' ' t1.First.cc ************************************************* set pages 999.owner '. ---------- 9i_recycle_syntax. dba_segments s.partition_name. .' s.'-') and buffer_pool <> 'KEEP' and object_type in ('TABLE'.. (select distinct address.name ' storage (buffer_pool recycle).*********************************************************** -.object_name and s. spool keep_syntax.subobject_name.object_type and nvl(s.segment_name = t1. To license this script for a commercial purpose.'-') = nvl(t1. .'INDEX') group by s. set heading off. get the table list -.owner = t1.001))*100 > 80 . dba_segments s where s.segment_name ' storage (buff er_pool keep).owner.' from t1.segment_type. set feedback off. select 'alter ' s. Use at your own risk. ttitle off.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.

object_owner owner, object_name name from v$sql_plan where operation = 'TABLE ACCESS' and options = 'FULL') p where a.address = p.address and t.owner = s.owner and t.table_name = s.segment_name and t.table_name = p.name and t.owner = p.owner and t.owner not in ('SYS','SYSTEM') and t.buffer_pool <> 'RECYCLE' having s.blocks > 10000 group by p.owner, p.name, t.num_rows, s.blocks UNION -- *********************************************************** -- Next, get the index names -- *********************************************************** select 'alter index ' owner '.' index_name ' storage (buffer_pool recycle);' from dba_indexes where owner '.' table_name in ( select p.owner '.' p.name from dba_tables t, dba_segments s, v$sqlarea a, (select distinct address, object_owner owner, object_name name from v$sql_plan where operation = 'TABLE ACCESS' and options = 'FULL') p where a.address = p.address and t.owner = s.owner and t.table_name = s.segment_name and

t.table_name = p.name and t.owner = p.owner and t.owner not in ('SYS','SYSTEM') and t.buffer_pool <> 'RECYCLE' having s.blocks > 10000 group by p.owner, p.name, t.num_rows, s.blocks ) ; spool off;

----------

hot_recycle_blocks.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 80; set pages 999; column column column column avg_touches format 999 myname heading 'Name' format a30 mytype heading 'Type' format a10 buffers format 999,999

SELECT object_type mytype, object_name myname, blocks, COUNT(1) buffers, 100*(COUNT(1)/totsize) pct_cache FROM sys.x$bh a, dba_objects b, dba_segments s, (select value totsize from v$parameter where name = 'db_cache_size') WHERE a.obj = b.object_id and tch=1 -- This line only works in 8.1.6 and above and b.object_name = s.segment_name and b.owner not in ('SYS','SYSTEM') GROUP BY object_type,

object_name, blocks, totsize HAVING 100*(COUNT(1)/totsize) > 5 ;

---------col col col col col

optimizer_index_cost_adj.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 ************************************************* c1 c2 c3 c4 c5 heading heading heading heading heading 'Average Waits for Full Scan Read I/O' format 9999.999 'Average Waits for Index Read I/O' format 9999.999 'Percent of I/O Waits for Full Scans' format 9.99 'Percent of I/O Waits for Index Scans' format 9.99 'Starting Value for optimizer index cost adj' format 999

select a.average_wait b.average_wait a.total_waits /(a.total_waits + b.total_waits) b.total_waits /(a.total_waits + b.total_waits) (b.average_wait / a.average_wait)*100 from v$system_event a, v$system_event b where a.event = 'db file scattered read' and b.event = 'db file sequential read' ; ); end; / select stuff from customer natural join orders natural join item natural join product where credit_rating * extended_credit > .07 and (qty_in_stock * velocity) /.075 < 30 or (sku_price / 47) * (qty_in_stock / velocity) > and

c1, c2, c3, c4, c5

47;

course = anthropology 610 ; customer_state = New Mexico ;

----------

plan9i.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 echo off; set feedback on set pages 999; column nbr_FTS column num_rows column blocks column owner column name column ch format format format format format format 999,999 999,999,999 999,999 a14; a24; a1;

column object_owner heading "Owner" format a12; column ct heading "# of SQL selects" format 999,999; select object_owner, count(*) ct from v$sql_plan where object_owner is not null group by object_owner order by ct desc ; --spool access.lst; set heading off; set feedback off; set heading on; set feedback on; ttitle 'full table scans and counts The "K" indicates that the table is in th e KEEP Pool (Oracle8).' select p.owner, p.name, t.num_rows, -- ltrim(t.cache) ch, decode(t.buffer_pool,'KEEP','Y','DEFAULT','N') K, s.blocks blocks, sum(a.executions) nbr_FTS from

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

ttitle 'Table access by ROWID and counts' select p.owner, p.name, t.num_rows, sum(s.executions) nbr_RID from dba_tables t, v$sqlarea s, (select distinct address, object_owner owner, object_name name from v$sql_plan where operation = 'TABLE ACCESS' and options = 'BY ROWID') p where s.address = p.address and t.table_name = p.name

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

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

p.999 format 999. format a30. ---------- plan10g.cc ************************************************* spool plan.table_name.executions) desc. set feedback on. p. . column ct heading "# of SQL selects" format 999. d.999 format a10. heading "Snapshot Time" format a15 column object_owner heading "Owner" format a12.lst. Use at your own risk. To license this script for a commercial purpose.end_interval_time. column nbr_FTS column num_rows column blocks column owner column name column ch column time format 99. set heading on.name order by sum(s.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. format a1. count(*) ct from dba_hist_sql_plan where object_owner is not null group by object_owner order by ct desc .'mm/dd/rr hh24') time. --spool access.999. break on time select object_owner.' select to_char(sn. ttitle 'full table scans and counts The "K" indicates that the table is in th e KEEP Pool (Oracle8).lst set echo off set feedback on set pages 999. contact info@rampant.999 format 9.owner.

. p. a25. s.buffer_pool.blocks blocks. t. dba_segments s. s. t.sql_id and t. p. object_name name from dba_hist_sql_plan pl where operation = 'TABLE ACCESS' and options = 'FULL') p where a. dba_hist_sqlstat a. dba_hist_sqlstat a.999 999.name and t.p. (select distinct pl.owner = s.owner. t.ltrim(t.'SYSTEM') having sum(a. t.'N') K.num_rows. object_owner owner. column column column column nbr_RID num_rows owner name format format format format 999.name. ttitle 'Table access by ROWID and counts' select to_char(sn.'DEFAULT'.owner not in ('SYS'. p.name.snap_id = sn.table_name = p. decode(t.executions_delta) > 1 group by to_char(sn. sum(a.999 a15.num_rows.owner and t.executions_delta) nbr_FTS from dba_tables t.'mm/dd/rr hh24').cache) ch.blocks order by 1 asc.owner. sum(a.p.999.'mm/dd/rr hh24') time.end_interval_time.num_rows.sql_id = p.executions_delta) nbr_RID from dba_tables t.'Y'.snap_id and a. cache.table_name = s.end_interval_time.sql_id.name.owner = p. t. dba_hist_snapshot sn.'KEEP'. p. -.owner and t.segment_name and t.buffer_pool.999.owner.

owner.snap_id = sn. p.table_name = p.sql_id. --************************************************* -.999 999.999 999. p.executions_delta) nbr_scans from dba_segments seg.blocks tbl_blocks.owner having sum(a. p. (select distinct pl.owner.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 = p.999. a20.name.p. a20.num_rows order by 1 asc.'mm/dd/rr hh24'). (select distinct pl. seg. object_owner owner. object_name name from dba_hist_sql_plan pl where operation = 'INDEX' and options = 'FULL SCAN') p . sum(s.table_name.end_interval_time.end_interval_time.999. object_owner owner.sql_id. t. object_name name from dba_hist_sql_plan pl where operation = 'TABLE ACCESS' and options = 'BY USER ROWID') p where a.'mm/dd/rr hh24') time. dba_hist_snapshot sn.sql_id and t. dba_indexes d. ttitle 'Index full scans and counts' select to_char(sn. dba_hist_sqlstat s.999 a9.dba_hist_snapshot sn.snap_id and a.executions_delta) > 9 group by to_char(sn.sql_id = p.name index_name.999. d.name and t.

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

username) user_name.executions_delta) nbr_scans from dba_hist_sqlstat s. (sum(decode(c.table_name. contact info@rampant. spool off ---------- top_20_sessions. dba_indexes d. object_owner owner. b.'physical writes'.name.'physical reads'.snap_id = sn.end_interval_time. p.executions_delta) > 9 group by to_char(sn.name.end_interval_time.cc ************************************************* select * from (select b.0)) + sum(decode(c.b.value.index_name = p.table_name.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.0)) + sum(decode(c.0)) + .'dd-mon-yy hh:mi:ss pm') logon_time.sql_id.username.name and s.name index_name.value. (select distinct pl. d.sql_id having sum(s.e.sql_id = p. sum(s.snap_id and s. decode (b. p. d.value.name.null.p. Use at your own risk.'mm/dd/rr hh24') time.owner.'physical writes direct'.spid os_id. To license this script for a commercial purpose.'mm/dd/rr hh24').sid sid.name.machine machine_name. to_char(logon_time. dba_hist_snapshot sn. p.ttitle 'Index unique scans and counts' select to_char(sn. object_name name from dba_hist_sql_plan pl where operation = 'INDEX' and options = 'UNIQUE SCAN') p where d.owner.name order by 1 asc. d.

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

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.b. ---------- awr_high_resource_sql. sys.dba_users c.operation like '%TABLE%' and a. decode (b. Use at your own risk.bytes / 1024 > 1024 group by c.group by b. contact info@rampant.user_id = d.object_owner (+) = b. username.owner and a. 'TABLE PARTITION') and a. count(a.cc ************************************************* select sql_text.object_name (+) = b. d.sid.segment_name and b.username.username order by 2 desc .hash_value = a.null. disk_reads. sys.sql select c.v_$sql d where a.machine.username username.e.name. b. buffer_gets.options = 'FULL' and c.parsing_user_id and d.username).dba_segments b.segment_type IN ('TABLE'. sys. to_char(logon_time.hash_value and b.'dd-mon-yy hh:mi:ss pm') order by 6 desc) where rownum < 21 ? awr_high_scan_sql.spid.v_$sql_plan a. disk_reads_per_exec. .hash_value) scan_count from sys.

sorts .all_users b where a.executions .0. elapsed_time.rows_processed . b. runtime_mem.disk_reads/greatest(a.1. hash_value from (select sql_text .disk_reads . persistent_mem .round(100 * a.2) hit_ratio.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. a. a. 100 .executions. hash_value from sys. executions. a. sys. Use at your own risk.1).user_id and b. sharable_mem. contact info@rampant.2) disk_reads_per_exec. round((a.disk_reads/decode(a. a.parse_calls .username not in ('sys'. persistent_mem.v_$sqlarea a.parse_calls. a.first_load_time . a.'system') order by 3 desc) where rownum < 21 ---------- awr_cartesian_sum. count(*) total_cartesian_joins .cc ************************************************* select count(distinct hash_value) carteisan_statements.parsing_user_id=b. To license this script for a commercial purpose. elapsed_time. address. hit_ratio.buffer_gets .buffer_gets. sorts. runtime_mem. cpu_time. rows_processed. a. cpu_time. address. sharable_mem . first_load_time.username .executions)). a.

cc ************************************************* select sql_text. 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.dba_segments b. total_large_scans.from sys.v_$sql where hash_value in (select hash_value from sys. count(*) total_large_scans.cc ************************************************* select * from sys. . sys.v_$sql_plan where options = 'CARTESIAN' and operation LIKE '%JOIN%' ) order by hash_value. executions.v_$sql_plan a. Use at your own risk. executions * total_large_scans sum_large_scans from (select sql_text. executions from sys. ---------- awr_large_scan_count. To license this script for a commercial purpose. Use at your own risk.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. contact info@rampant.v_$sql_plan where options = 'CARTESIAN' and operation like '%JOIN%' ---------- awr_sql_cartesian.

v_$sql c where a. .35)*/ emp_name from emp order by ename. contact info@rampant.bytes / 1024 > 1024 group by sql_text.cc ************************************************* c1 c2 c3 c4 heading heading heading heading Begin Interval time SQL ID Exec Delta Buffer Gets Delta format format format format a8 a13 9.object_owner (+) = b. Use at your own risk.8)*/ emp_name from emp order by ename. bon) */ from emp. -.999 col col col col .object_name (+) = b. bon where .A valid hint select /*+ full parallel(emp. 'TABLE PARTITION') and a. To license this script for a commercial purpose. executions) order by 4 desc .segment_name and b.options = 'FULL' and c.owner and a. -.sys. . select /*+ ordered use_hash (emp.hash_value and b. ---------- awr_sqlstat_deltas.hash_value = a. dept.segment_type IN ('TABLE'.An invalid hint select /*+ first_rows parallel(emp.999 9. dept) use_nl (sal.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. sal.operation LIKE '%TABLE%' and a.

999 9.executions_delta c3.buffer_gets_delta c3. sql. sql.buffer_gets_delta c4.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. sql. sql. sql.col col col col c5 c6 c7 c8 heading heading heading heading Disk Reads Delta format IO Wait Delta format Application Wait Delta format Concurrency Wait Delta format 9.iowait_delta c6.999 999.apwait_delta c7.999 9.executions_delta c2. contact info@rampant.999 col col col col col col col col col accept sqlid prompt Enter SQL ID: ttitle time series execution for &sqlid break on c1 select to_char(s. Use at your own risk.ccwait_delta c8 from dba_hist_sqlstat sql.disk_reads_delta c5.999 9.sql_id c2.999 999.999 9. To license this script for a commercial purpose.999 999.999 break on c1 select to_char(s.begin_interval_time. dba_hist_snapshot s where s. sql. ---------- awr_sqlstat_deltas_detail. c2 . sql. mm-dd hh24 ) c1.snap_id order by c1. .begin_interval_time.999 9. sql. mm-dd hh24 ) c1.snap_id = sql. sql.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 9.999 9.

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

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

sql_id = st.break on c1 skip 2 break on c2 skip 2 select to_char(sn.snap_id = sn. p. avg(p.begin_interval_time.object_name = 'CUSTOMER_DETS' and p.snap_id group by to_char(sn.object_owner.'mm-dd hh24').999.io_cost) c5 from dba_hist_sql_plan p.object_name c3.object_name is not null and p. p. p. dba_hist_snapshot sn where p. Use at your own risk.999.cpu_cost) c4.999 99. dba_hist_sqlstat st. contact info@rampant.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. p.999.2.object_type.object_owner <> 'SYS' and p.999 99. p.object_name order by 1.sql_id and st.begin_interval_time.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. p.'mm-dd hh24') c0.object_type c2. To license this script for a commercial purpose.object_owner c1.999 99.999.999 col col col col col accept nested_thr char prompt Enter Nested Join Threshold: ttitle select Nested Join Threshold &nested_thr .3 desc . ---------- awr_nested_join_alert. avg(p.

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

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

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

options c2.'d') order by c2.object_name.snap_id = sn. contact info@rampant. to_char(sn. c1.'d') count(1) from dba_hist_sql_plan p. .999 999.cc ************************************************* Please enter SQL ID: format format format format format a20 a20 a25 999.from ( select p. dba_hist_sqlstat s.sql_id and s.snap_id group by p.c1 ) .sql_id = s.end_interval_time.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.object_name to_char(sn. c3 ---------- awr_sql_details. object_name c3.id.sql_id = '&sqlid' order by p.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. dba_hist_snapshot sn where p. search_columns c4. cardinality c5 from dba_hist_sql_plan p where p. To license this script for a commercial purpose.end_interval_time.object_owner <> 'SYS' and p. c2. Use at your own risk.

Use at your own risk.begin_interval_time.search_columns c2.'yy-mm-dd hh24') c1. count(*) c3 from dba_hist_snapshot sn.cc ************************************************* ttile Table Access Operation Counts Per Snapshot Period col c1 heading Begin Interval time format a20 col c2 heading Operation format a15 col c3 heading Option format a15 . dba_hist_sql_plan p.sql_id and sn.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. contact info@rampant. To license this script for a commercial purpose. To license this script for a commercial purpose. p.---------- index_usage_hr.snap_id and p. Use at your own risk. dba_hist_sqlstat st where st.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.search_columns.999.cc ************************************************* col c1 heading Begin Interval time format a20 col c2 heading Search Columns format 999 col c3 heading Invocation Count format 99. ---------- awr_access_counts.object_name = &idxname' group by begin_interval_time. contact info@rampant.sql_id = p.999 break on c1 skip 2 accept idxname char prompt Enter Index Name: ttitle Invocation Counts for index &idxname select to_char(sn.snap_id = st.

snap_id = sn.'yy-mm-dd hh24') c1. f.options c3. dba_hist_snapshot sn where p.snap_id group by to_char(sn. contact info@rampant. dba_hist_snapshot sn where p.begin_interval_time. dba_hist_sqlstat s.col c4 heading Object Count format 999.999 break on c1 skip 2 break on c2 skip 2 select to_char(sn. count(1) c4 from dba_hist_sql_plan p.cc ************************************************* col c1 heading Begin Interval Time format a20 col c2 heading Index Table Scans format 999.options order by 1.operation.begin_interval_time. p.2.999 select i.operation c2.c2 c3 from ( select to_char(sn. Use at your own risk.'yy-mm-dd hh24'). count(1) c2 from dba_hist_sql_plan p.begin_interval_time. p.c2 c2.3.'yy-mm-dd hh24') c1.c1 c1.sql_id and s.object_owner <> 'SYS' and p. p.object_owner <> 'SYS' and . dba_hist_sqlstat s. ---------- awr_sql_full_scans. i. 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.999 col c3 heading Full Table Scans format 999. p.sql_id = s.

sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. dba_hist_snapshot sn where p. To license this script for a commercial purpose.p.operation like '%TABLE ACCESS%' and p.options like '%INDEX%' and p. ---------- awr_full_table_scans.'yy-mm-dd hh24') order by 1 ) i.options = 'FULL' and p. Use at your own risk.c1 . ( select to_char(sn.sql_id = s. dba_hist_sqlstat s.sql_id and s.snap_id group by to_char(sn.begin_interval_time.object_owner <> 'SYS' and p.sql_id = s. count(1) c2 from dba_hist_sql_plan p.operation like '%TABLE ACCESS%' and p.'yy-mm-dd hh24') order by 1 ) f where i.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 format a20 format 999.999 .snap_id = sn.begin_interval_time.snap_id group by to_char(sn.snap_id = sn.begin_interval_time. contact info@rampant.c1 = f.'yy-mm-dd hh24') c1.sql_id and s.

blocks > 1000 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.begin_interval_time. dba_hist_sqlstat s. count(1) c2 from dba_hist_sql_plan p.object_owner <> 'SYS' and p.'hh24') c1.object_owner = o. count(1) c4 from dba_hist_sql_plan p.'yy-mm-dd hh24') order by 1.sql_id = s. contact info@rampant.begin_interval_time. To license this script for a commercial purpose. dba_hist_sqlstat s.select to_char(sn.segment_name and o.object_name = o.snap_id = sn.'yy-mm-dd hh24') c1.operation like '%TABLE ACCESS%' and p.snap_id group by to_char(sn.owner and p.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. ---------- awr_sql_access_hr.sql_id and s. dba_segments o where p. dba_hist_snapshot sn. dba_hist_snapshot sn. Use at your own risk.999 .begin_interval_time. format a20 format 999.options like '%FULL%' and p.

blocks > 1000 format a20 format 999.object_name = o.sql_id and s.owner and p.object_owner <> 'SYS' and p. ---------- awr_sql_access_day.owner and p.sql_id = s.object_name = o.snap_id group by to_char(sn. dba_segments o where p.snap_id = sn.dba_segments o where p.operation like '%TABLE ACCESS%' and p.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. dba_hist_snapshot sn.begin_interval_time.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.object_owner <> 'SYS' and p.segment_name and o.object_owner = o.begin_interval_time. dba_hist_sqlstat s. contact info@rampant.options like '%FULL%' and p. To license this script for a commercial purpose.object_owner = o.segment_name and o.'hh24') order by 1.'day') c1.blocks > 1000 and p. count(1) c2 from dba_hist_sql_plan p. Use at your own risk.999 .

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

begin_interval_time.begin_interval_time.snap_id group by to_char(sn.segment_name and o. ( select to_char(sn.sql_id = s.'yy-mm-dd count(1) c2 from dba_hist_sql_plan p.sql_id and s.and p.object_owner = o.'yy-mm-dd order by 1 ) i where f.begin_interval_time.snap_id group by to_char(sn. dba_segments o where p.'yy-mm-dd count(1) c2 from dba_hist_sql_plan p.snap_id = sn.blocks < 1000 and p. dba_hist_sqlstat s. ( select to_char(sn.'yy-mm-dd order by 1 ) s.operation like '%INDEX%' and p.begin_interval_time. dba_hist_snapshot sn.c1 and f.object_owner <> 'SYS' and p. hh24') .begin_interval_time.operation like '%INDEX%' and p. dba_hist_snapshot sn where p.snap_id = sn.snap_id group by to_char(sn. dba_hist_sqlstat s.c1 .c1 = s.c1 = i.'yy-mm-dd order by 1 ) f.object_owner <> 'SYS' and p. hh24') hh24') c1.sql_id and s.sql_id = s.snap_id = sn. hh24') hh24') c1.owner and p.sql_id = s.sql_id and s.object_name = o.

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

999. To license this script for a commercial purpose.and p. Use at your own risk.999. ---------- awr_hash_join_alert. dba_hist_sqlstat st where st.sql_id = s.snap_id = sn.999.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.'day') order by 1 ) f where i.snap_id = st.sql_id and s.begin_interval_time. count(*) c2.operation = 'HASH JOIN' having count(*) > &hash_thr group by begin_interval_time.999 col col col col col accept hash_thr char prompt ttitle Enter Hash Join Threshold: Hash Join Threshold &hash_thr select to_char(sn. sum(st. .999.disk_reads_delta) c4.cc ************************************************* c1 c2 c3 c4 c5 heading heading heading heading heading Date Hash Join Count Rows Processed Disk Reads CPU Time format format format format format a20 99.c1 = f.999 99. sum(st.begin_interval_time.999 99.cpu_time_delta) c5 from dba_hist_snapshot sn. dba_hist_sql_plan p.sql_id and sn. contact info@rampant.snap_id group by to_char(sn.999 99.c1 .sql_id = p.options = 'FULL' and p.snap_id and p. sum(st.'yy-mm-dd hh24') c1.rows_processed_delta) c3.

advisor_name= ADDM and l. count(*) c1. TEXT .---------- addm_rpt.cc ************************************************* col c1 heading invocation count format 9. 2) c2 from v$active_session_history where . To license this script for a commercial purpose. round(count(*)/sum(count(*)) over (). contact info@rampant.cc ************************************************* set long 1000000 set pagesize 50000 column get_clob format a80 select dbms_advisor.cust_nbr . ALL ) as first_ADDM_report ---------- ash_display_active_sql.task_id and t. dba_advisor_log l where t.999 col c2 heading percentage of load format 99 select sql_id. Use at your own risk.task_id) from dba_advisor_tasks t.status= COMPLETED ). To license this script for a commercial purpose. from dba_advisor_tasks where task_id=( select max(t. contact info@rampant.cust_nbr = o.get_task_report(task_name.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. Use at your own risk.customer_name) = upper(:v1) and c.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.task_id = l. order o where upper(c.

event_id = evt. contact info@rampant. count(*) from v$active_session_history ash.sample_time > sysdate . Use at your own risk.1/24/60 and session_type <> group by sql_id order by count(*) desc.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.sql_id.cc ************************************************* select ash. v$event_name evt where ash.session_state = WAITING and ash.wait_class = User I/O group by sql_id order by count(*) desc. ---------- ash_event_rollup. BACKGROUND ---------- ash_display_sql_io_waits.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. Use at your own risk. contact info@rampant. To license this script for a commercial purpose.cc ************************************************* ttitle 'High waits on events Rollup by hour' .sample_time > sysdate 1/24/60 and ash. To license this script for a commercial purpose.event_id and evt.

sql_fulltext like %orders% having count(*) > 1 group by h.sample_time.cc ************************************************* select h. e.'yyyy-mm-dd HH24').sql_id.column column column column column mydate heading event total_waits time_waited total_timeouts 'Yr.sql_id order by 2 DESC. time_waited ---------- count_sql_invocations.event. v$sql s where h.999.event not like '%timer' and e.'yyyy-mm-dd') skip select to_char(e. a30. .sql_id and s. 999. Use at your own risk.event order by 1 . 9.999. count(e. Mo Dy Hr' format format heading 'tot waits' format heading 'time wait' format heading 'timeouts' format 1.sql_id = s. count(*) from dba_hist_active_sess_history h. mydate.event not like '%message%' and e. 999.time_waited) from v$active_session_history e where e. To license this script for a commercial purpose.999. total_waits.event) sum(e.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.'yyyy-mm-dd HH24') e. a13. break on to_char(snap_time.event) > 100 group by to_char(e. contact info@rampant.event not like '%slave wait%' having count(e.sample_time.

snap_id = ash.ash_wait_time_by_day.current_file# and obj. wait_count.snap_id = snap.Copyright © 2005 by Rampant TechPress .---------- wait_time_detail.sql -. To license this script for a commercial purpose.999 select to_char(begin_interval_time. time from dba_hist_waitstat wait.file_name.'yyyy-mm-dd hh24:mi').current_obj# and wait_count > 50 order by to_char(begin_interval_time.snap_id and df.'yyyy-mm-dd hh24:mi') snap_time. -.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.object_id = ash. object_type. object_name. dba_hist_snapshot snap. dba_objects obj where wait. -.************************************************* -.snap_id and wait.file_id = ash. Use at your own risk. file_name . contact info@rampant. dba_hist_active_sess_history ash.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.999 999. dba_data_files df.

'Day') "Hour". To license this script for a commercial purpose.EVENT_ID and to_char(h.wait_class <> 'Idle' group by TO_CHAR(h. v$event_name n where h.session_type = 'FOREGROUND' and h.'HH24') = '12' and n.sample_time.event "Wait Event".event_id = n. sum(h.------- This script is free for non-commercial purposes with no warranties. ---------- ash_total_event_wait_time.sample_time. .sample_time. SUM(h.event_id = n.event order by 2 DESC. contact info@rampant.session_state = 'ON CPU' and h.wait_time/100) "Wait Time (Sec)" from v$active_session_history h.session_type = 'FOREGROUND' and h. contact info@rampant.EVENT_ID and n.cc ************************************************* select h.session_state = 'ON CPU' and h.cc ************************************************* select TO_CHAR(h. v$event_name n where h.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.wait_class <> 'Idle' group by h. Use at your own risk.wait_time/100) "Total Wait Time (Sec)" from v$active_session_history h.'Day'). Use at your own risk.

To license this script for a commercial purpose.---------- ash_datafile_waits.sid.event_id and e.event_id = h.username order by 3.username. ---------- ash_object_wait_time. s. sum(h.wait_class <> 'Idle' and s. contact info@rampant. COUNT(*) Wait Number .session_id = s.cc ************************************************* select f.file_name order by 3 DESC. v$event_name e where h.username IS NOT NULL group by s. To license this script for a commercial purpose.wait_time + h.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. Use at your own risk. s. SUM(h. v$session s. Use at your own risk.file_id group by f.sid.time_waited) "total wait time" from v$active_session_history h. dba_data_files f where h. ? ash_user_wait_time.cc ************************************************* .sql select s.sid and e. contact info@rampant.time_waited) Total Time Waited from v$active_session_history h.file_name Data File .current_file# = f.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties.

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

cc ************************************************* drop type BlckFreeSpaceSet. total_req#. cum_wait_time from dba_hist_enqueue_stat natural join dba_hist_snapshot where cum_wait_time > 0 order by begin_interval_time. total_wait#. drop type BlckFreeSpace.---------- awr_enqueue_waits. Use at your own risk. contact info@rampant. cum_wait_time. create type BlckFreeSpace as object ( seg_owner varchar2(30). fs1 number. eq_type.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. . failed_req#. seg_name varchar2(100). contact info@rampant. succ_req#. req_reason.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.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. fs2 number. To license this script for a commercial purpose. seg_type varchar2(30). To license this script for a commercial purpose. ---------- awr_list_seg_block_space. Use at your own risk.

null. . create or replace function BlckFreeSpaceFunc (seg_owner IN varchar2. fs4_b number.s. outRec.fb := := := := := fs1_bl.seg_owner := rec.seg_name := rec.fs3 outRec.null. u_bl number.null. fulb number. unformatted_blocks => u_bl. fs2_b number. fs1_bytes => fs1_b.null.owner. outRec. fs4_bl.null ).null. fs2_bl number.fs3 number. fs4_bl number.owner.fs2 outRec. Pipe Row (outRec).fs4 outRec.seg_type := rec. fs4_blocks => fs4_bl. fs4 number.segment_type.null.space_usage( segment_owner => rec. fs3_bl number.segment_type. fs3_b number.segment_type from dba_segments s w here owner = seg_owner and segment_type = nvl(seg_type. begin for rec in (select s.s. outRec.segment_type) ) loop dbms_space. create type BlckFreeSpaceSet as table of BlckFreeSpace. fulbl number. segment_name => rec. fs2_bytes => fs2_b.segment_name.segment_name. fs1_bl number. u_b number. fs3_bytes => fs3_b. unformatted_bytes => u_b ). fs2_bl. full_bytes => fulb. fb number ). fulbl. fs3_bl. fs1_b number.owner. segment_type => rec. full_blocks => fulbl. fs1_blocks => fs1_bl.fs1 outRec. outRec. end loop. fs3_blocks => fs3_bl. fs4_bytes => fs4_b.segment_name. seg_type in varchar2 default null) return BlckFreeSpaceSet pipelined is outRec BlckFreeSpace := BlckFreeSpace(null. fs2_blocks => fs2_bl.

Use at your own risk. Use at your own risk. v_fs3_blocks number.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. v_unformatted_bytes number. 'TABLE' ) ) order by fs4 desc . 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. end.999 9. v_fs1_bytes number. To license this script for a commercial purpose.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. v_fs2_blocks number.999 9. v_fs2_bytes number. contact info@rampant. contact info@rampant.cc ************************************************* DECLARE v_unformatted_blocks number.return. v_fs1_blocks number. .999 accept user_name prompt break on seg_owner Enter Segment Owner: select * from Table ( BlckFreeSpaceFunc ('&user_name'. / ---------- free_space_by_segment.999 9.999 9. ---------- block_count.

v_unformatted_blocks.job_schedule. v_full_blocks number. dbms_output. dbms_output.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. v_fs4_bytes number. -.'mm/dd/rr hh24') time. v_fs2_bytes. -. v_fs1_blocks. upper('&1')) . v_fs4_blocks number. p.Parameters: -1) Specific USERNAME or ALL which doesn't limit output.name. v_fs4_blocks. dbms_output. v_fs2_blocks. dbms_output. end. To license this script for a commercial purpose. v_unfor matted_bytes. 'TEST'.put_line('Unformatted Blocks = ' v_unformatted_blocks). v_full_blocks.end_interval_time. v_fs3_blocks . owner.cc ************************************************* select to_char(sn. v_fs3_bytes.num_rows.space_usage ('SYSTEM'. 'TABLE'.put_line('FS3 Blocks = ' v_fs3_blocks). . v_full_bytes number. 'ALL'. dbms_output.sql -. v_full_bytes). BEGIN dbms_space. ---------- display_full_table_scans. . .put_line('FS4 Blocks = ' v_fs4_blocks).Parameters: -1) Specific USERNAME or ALL which doesn't limit output.put_line('FS2 Blocks = ' v_fs2_blocks).put_line('Full Blocks = ' v_full_blocks). contact info@rampant. v_fs4_bytes.put_line('FS1 Blocks = ' v_fs1_blocks). v_fs1_bytes. repeat_interval from dba_scheduler_schedules where owner = decode(upper('&1'). p. Use at your own risk. dbms_output.v_fs3_bytes number. t.owner.***************************************************************** set verify off select owner. schedule_name.

owner and t.owner and t. p.'KEEP'.executions_delta) nbr_FTS from dba_tables t.name and t.'N') K.table_name = p. contact info@rampant. t.snap_id = sn.num_rows. s. ---------- rac_grid_block_usage. dba_hist_sqlstat a.end_interval_time. t. To license this script for a commercial purpose. (select distinct pl.'DEFAULT'.table_name = s. cache.blocks order by 1 asc. dba_segments s.buffer_pool.sql ************************************************* Copyright © 2005 by Rampant TechPress This script is free for non-commercial purposes with no warranties. s.executions_delta) > 1 group by to_char(sn. object_name name from dba_hist_sql_plan pl where operation = 'TABLE ACCESS' and options = 'FULL') p where a.'mm/dd/rr hh24').sql_id.segment_name and t. object_owner owner.snap_id and a.'Y'.p.decode(t.name.owner = p.sql_id and t.sql_id = p.blocks blocks.owner.cc ************************************************* break on report compute sum of distinct_blocks on report compute sum of blocks on report set lines 132 pages 57 @title132 'Block Usage Inside SGA Block Buffers' . t.'SYSTEM') having sum(a.owner = s.owner not in ('SYS'. sum(a.buffer_pool. Use at your own risk. dba_hist_snapshot sn.

tablespace_name.spool rep_out\&db\block_usage SELECT a.tablespace_name) ts_n ame.decode(b.file#=b.b.'UNUSED'. a.tablespa ce_name) order by a. dba_data_files b WHERE a.tablespace_name.file_id(+) GROUP BY a.file# file_number.block#) Blocks.block#) Distinct_blocks FROM GV$BH a.b. COUNT(a. COUNT (DISTINCT a. decode(b.null.INST_ID.inst_id / spool off ttitle off .'UNUSED'.file# a.null.file#.INST_ID. a.

Sign up to vote on this title
UsefulNot useful