home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a524 / 28.ddi / admin / estat.sql < prev    next >
Encoding:
Text File  |  1991-03-04  |  4.7 KB  |  145 lines

  1. rem
  2. rem $Header: estat.sql,v 6002700.1 89/05/22 17:06:46 rcs Exp $ estat.sql Copyr (c) 1989 Oracle
  3. rem
  4. rem RDBMS660027,DISK$DEV1:[V6SOURCE.UTL.60027]
  5. Rem Copyright (c) 1988 by Oracle Corporation
  6. Rem NAME
  7. Rem    ESTAT.SQL - collect Ending STATistics
  8. Rem  FUNCTION
  9. Rem    This script will generate a report (in "report.txt") which will contain
  10. Rem    usefull information for performance monitoring.  In particular
  11. Rem    information from v$sysstat, v$latch, and v$rollstat.
  12. Rem  NOTES
  13. Rem    Don't worry about errors during "drop table"s, they are normal.
  14. Rem  MODIFIED
  15. Rem   Loaiza     04/04/89 - fix run dates to do minutes instead of months
  16. Rem   Loaiza     03/31/89 - add kqrst usage column
  17. Rem   Jloaiza    03/16/89 - improve names and formats
  18. Rem   Jloaiza    03/09/89 - make kqrst columns intelligible
  19. Rem   Jloaiza    02/23/89 - changed table names, added dates
  20. Rem   Martin     02/22/89 - Creation
  21. set echo on;
  22. connect internal;
  23.  
  24. drop table stats$stats;
  25. drop table stats$latches;
  26. drop table stats$roll;
  27. drop table stats$files;
  28. drop table stats$kqrst;
  29. drop table stats$end_stats;
  30. drop table stats$end_latch;
  31. drop table stats$end_roll;
  32. drop table stats$end_file;
  33. drop table stats$end_kqrst;
  34. create table stats$end_stats as select * from v$sysstat;
  35. create table stats$end_latch as select * from v$latch;
  36. create table stats$end_roll as select rownum undo#,rssize,gets,waits,writes from v$rollstat;
  37. create table stats$end_file as select * from stats$file_view;
  38. create table stats$end_kqrst as select * from x$kqrst;
  39.  
  40. create table stats$stats as
  41. select  e.value-b.value change , n.name
  42.     from v$statname n ,  stats$begin_stats b , stats$end_stats e
  43.     where n.statistic# = b.statistic# and n.statistic# = e.statistic#;
  44.  
  45. create table stats$latches as
  46. select 
  47.     e.waits-b.waits waits, 
  48.     e.immediates-b.immediates immediates,
  49.     e.timeouts-b.timeouts timeouts,
  50.     e.nowaits-b.nowaits nowaits,
  51.     e.successes-b.successes successes ,
  52.     n.name
  53.     from v$latchname n ,  stats$begin_latch b , stats$end_latch e
  54.     where n.latch# = b.latch# and n.latch# = e.latch#;
  55.  
  56. create table stats$roll as
  57. select  e.gets-b.gets trans_tbl_gets, 
  58.     e.waits-b.waits trans_tbl_waits, 
  59.     e.writes-b.writes undo_bytes_written,
  60.     e.rssize segment_size_bytes
  61.     from stats$begin_roll b , stats$end_roll e
  62.         where e.undo# = b.undo#;
  63.  
  64. create table stats$files as
  65. select b.ts table_space,
  66.        b.name file_name,
  67.        e.pyr-b.pyr phys_reads,
  68.        e.pbr-b.pbr phys_blks_rd,
  69.        e.prt-b.prt phys_rd_time,
  70.        e.pyw-b.pyw phys_writes,
  71.        e.pbw-b.pbw phys_blks_wr,
  72.        e.pwt-b.pwt phys_wrt_tim
  73.   from stats$begin_file b, stats$end_file e
  74.  where b.name=e.name;
  75.  
  76. create table stats$kqrst as
  77. select 
  78.        b.kqrsttxt name,
  79.        e.kqrstgrq-b.kqrstgrq get_reqs,
  80.        e.kqrstgmi-b.kqrstgmi get_miss,
  81.        e.kqrstsrq-b.kqrstsrq scan_reqs,
  82.        e.kqrstsmi-b.kqrstsmi scan_miss,
  83.        e.kqrstmrq-b.kqrstmrq mod_reqs,
  84.        e.kqrstusg cur_usage
  85. from stats$begin_kqrst b, stats$end_kqrst e
  86. where b.indx=e.indx;
  87.  
  88. insert into stats$dates 
  89.    select to_char(sysdate, 'dd-mon-yy hh:mi:ss') from stats$dual;
  90.  
  91. spool report.txt;
  92. set charwidth 30;
  93. set numwidth 11;
  94. rem The total is the total value of the statistic between the time
  95. rem bstat was run and the time estat was run.
  96. select n1.name "Statistic", 
  97.        n1.change "Total", 
  98.        trunc(n1.change/n2.change,2) "Per Trans" 
  99.    from stats$stats n1, stats$stats n2
  100.    where n2.name='user commits'
  101.    order by n1.name;
  102. set charwidth 48;
  103. set numwidth 12;
  104. rem I/O should be spread evenly accross drives. A big difference between
  105. rem phys_reads and phys_blks_rd implies table scans are going on.
  106. select * from stats$files;
  107. set charwidth 26;
  108. set numwidth 9;
  109. rem Timeouts should be low.  Successes should be very close to nowaits.
  110. select name, waits, immediates, timeouts, nowaits, successes from stats$latches order by name;
  111. set numwidth 19;
  112. rem Waits_for_trans_tbl high implies you should add rollback segments.
  113. select * from stats$roll;
  114. set charwidth 20;
  115. set numwidth 8;
  116. rem get_miss and scan_miss should be very low compared to the requests.
  117. rem cur_usage is the number of entries in the cache that are being used.
  118. select * from stats$kqrst;
  119. rem The init.ora parameters currently in effect:
  120. show parameters;
  121. rem The times that bstat and estat were run.
  122. select * from stats$dates;
  123. spool off;
  124.  
  125. drop table stats$dual;
  126. drop table stats$dates;
  127. drop table stats$begin_stats;
  128. drop table stats$begin_latch;
  129. drop table stats$begin_roll;
  130. drop table stats$begin_file;
  131. drop table stats$begin_kqrst;
  132. drop view stats$file_view;
  133. drop table stats$stats;
  134. drop table stats$latches;
  135. drop table stats$roll;
  136. drop table stats$files;
  137. drop table stats$kqrst;
  138. drop table stats$end_stats;
  139. drop table stats$end_latch;
  140. drop table stats$end_roll;
  141. drop table stats$end_file;
  142. drop table stats$end_kqrst;
  143. disconnect;
  144.  
  145.