¿À·£ÁöÀÇ health check ½ºÅ©¸³Æ®
ÀÛ¼ºÀÚ °ü¸®ÀÚ ÀÛ¼º½Ã°£ 2006-03-28 12:41:05
 

spool health.txt
doc

  Orange for Oracle health check script

  Modified by OCM Yeonhong Min

~~~ GENERAL ~~~

Oracle Instance Information

    Purpose - ´ë»ó µ¥ÀÌÅͺ£À̽º ÀνºÅϽºÀÇ ±âº»Á¤º¸¸¦ È®ÀÎÇÑ´Ù.
#
set pages 40
set line 132
col host format a20

select name "DB Name",  instance_number "Inst ID", instance_name "Inst Name",
      host_name "Host", version "Version", startup_time "Startup Time",
      parallel "Parallel", log_mode "Log Mode", archiver "Archiver"
from v$instance, v$database
/

/*
doc
Current Session Count
    Purpose - ´ë»ó µ¥ÀÌŸº£À̽º¿¡ Á¢¼ÓµÇ¾î ÀÖ´Â ¸ðµç Session°ú ÇöÀç ÀÛ¾÷ÁßÀÎ SessionÀÇ ¼ö¸¦ È®ÀÎÇÑ´Ù.
#
*/

select to_char(sysdate,'yyyy/mm/dd hh24:mi:ss') "Time",
count(*) "Total Sessions",
count(decode(status, 'ACTIVE',1) ) "Active Sessions"
from v$session
/

/*
doc
Invalid Object Count

    Purpose - ¿ÀºêÁ§Æ®ÀÇ À¯Çüº°·Î Invalid»óÅÂÀÎ ¿ÀºêÁ§Æ®ÀÇ ¼ö¸¦ Á¡°ËÇÑ´Ù.

    Description - Invalid Object°¡ »ý±â´Â ¿øÀÎÀº ´Ù¾çÇѵ¥, ÀϹÝÀûÀ¸·Î ±ÇÇÑÀ̳ª SynonymÀÇ
            ´©¶ô¿¡ ÀÇÇØ ¹ß»ýÇϰųª, ºä ¶Ç´Â ÇÁ·Î½ÃÁ®, Æ®¸®°Å µîÀÌ ÂüÁ¶ÇÏ°í ÀÖ´Â »óÀ§ ¿ÀºêÁ§Æ®ÀÇ
            º¯°æ ¹× »èÁ¦ µî¿¡ ÀÇÇØ ¹ß»ýÇÑ´Ù.

    Guide - Invalid Object¸¦ ÄÄÆÄÀÏÇÏ¿© ÁÖ´Â °ÍÀº PC¿¡¼­ Scandisk¸¦ ¼öÇàÇÏ´Â °Í°ú
      ¸¶Âù°¡Áö·Î µ¥ÀÌÅͺ£À̽ºÀÇ °ü¸®¿¡ ÀÖ¾î °¡Àå ±âº»ÀûÀÎ ÀÛ¾÷¿¡ ÇØ´çÇϹǷΠÀ̸¦
      ÁÖ±âÀûÀ¸·Î Á¡°ËÇÏ°í ÇØ°áÇÏ¿© ÁÖ´Â °ÍÀÌ ÁÁ´Ù. ƯÈ÷, Export/Import ÀÛ¾÷¼öÇà ÈÄ,
      ¶Ç´Â ¿À¶óŬ ¹öÀü upgrade³ª patchÀû¿ë ÈÄ¿¡ ´Ù¼öÀÇ ¿ÀºêÁ§Æ®µéÀÌ Invalid»óÅ·Î
      ºüÁ®¹ö¸®´Â °æ¿ì°¡ ¸¹ÀÌ ¹ß»ýÇϹǷΠÀÌ·¯ÇÑ ÀÛ¾÷ ÈÄ¿¡´Â ¹Ýµå½Ã Invalid ObjectÀÇ
      Á¸Àç¿©ºÎ¸¦ Á¡°ËÇÏ¿© ÄÄÆÄÀÏÀ» ¼öÇàÇÏ¿© ÁÖ¾î¾ß ÇÑ´Ù. 
#
*/

select /*+ ORDERED_PREDICATES  */
object_type "Object Type",
count(*) "Invalid Count"
from dba_objects
where status  = 'INVALID'
group by object_type
/

/*
doc
Current Transactions

    Purpose - ÇöÀç ÁøÇàÁßÀÎ Æ®·£Àè¼ÇµéÀÇ ¸ñ·Ï°ú °ü·ÃÁ¤º¸¸¦ È®ÀÎÇÑ´Ù.

    Description - [Recur]Àº Recursive Æ®·£Àè¼Ç ¿©ºÎ, [RBS]´Â ÇØ´ç Æ®·£Àè¼ÇÀÌ »ç¿ëÁßÀÎ
      Rollback Segment À̸§, [UBLKS]´Â Æ®·£Àè¼ÇÀÌ »ç¿ëÇÑ Rollback BlockÀÇ ¼ö,
      [URECS]´Â Æ®·£Àè¼ÇÀÌ »ý¼ºÇÑ  Rollback RecordÀÇ ¼ö, [L_IO]´Â Æ®·£Àè¼ÇÀÌ À¯¹ßÇÑ
      Logical IO¼ö,  [P_IO]´Â Æ®·£Àè¼ÇÀÌ À¯¹ßÇÑ Physical IOÀÇ ¼ö¸¦ ÀǹÌÇÑ´Ù.

#
*/

select /*+ ordered */ s.username,
    s.sid sid ,
    s.machine "Machine" ,
    s.program "Pgm",
    t.status "Status",
    RECURSIVE "Recur",
    to_char(to_date(t.start_time, 'mm/dd/yy HH24:MI:SS'), 'yyyy/mm/dd hh24:mi:ss') "StartTime",
    r.name  "RBS",
    t.used_ublk  "UBLKS",
    t.used_urec "URECS",
    t.log_io "L_IO",
    t.PHY_IO  "P_IO"
from v$transaction t, v$session s, v$rollname r, v$process p
where s.saddr = t.ses_addr and t.xidusn = r.usn
    and s.paddr = p.addr
    order by used_ublk
/

/*
doc
Resource Limit

    Purpose - µ¥ÀÌŸº£À̽ºÀÇ ½Ã½ºÅÛ¸®¼Ò½ºÀÇ ÇÒ´ç³»¿ª°ú ¼Ò¸ðÇöȲÀ» È®ÀÎÇÑ´Ù.

    Description - ÀνºÅϽº ½ÃÀ۽à ÇÒ´çµÇ´Â ½Ã½ºÅÛÀÚ¿ø¿¡ ´ëÇÏ¿© ÇÒ´ç°ª°ú ¼Ò¸ðÇöȲÀ»
      ¸ð´ÏÅ͸µÇÏ¿© ÇÒ´çÀÚ¿øÀÌ ºÎÁ·ÇÒ °æ¿ì ÀûÀýÇÑ Á¶Ä¡¸¦ ÃëÇØÁÖ¾î¾ß ÇÑ´Ù. ´ëºÎºÐÀÇ °æ¿ì ´ëÀÀµÇ´Â
      ÃʱâÈ­ ÆĶó¹ÌÅ͸¦ ÅëÇØ ¼³Á¤°ªÀ» º¯°æÇÒ ¼ö ÀÖ´Ù. ÀÌ Á¤º¸´Â ¿À·»ÁöÀÇ Database Information
      Åø¿¡¼­ ¼ö½Ã·Î È®ÀÎÇÒ ¼ö ÀÖ´Ù.

    Guide - Resource Nameº°·Î Max util °ªÀÌ Limit °ª¿¡ ±ÙÁ¢Çϰųª °°Àº °ªÀÏ °æ¿ì¿¡´Â
            init.ora ÆÄÀÏ¿¡¼­ ÇØ´ç ¸®¼Ò½º¸¦ ¼³Á¤ÇÏ´Â ÃʱâÈ­ ÆĶó¹ÌÅÍÀÇ °ªÀ» ´Ã·ÁÁÖ¾î¾ß ÇÑ´Ù. 
#
*/

select RESOURCE_NAME "Resource Name",
      CURRENT_UTILIZATION "Current Util",
      MAX_UTILIZATION "Max Util",
      INITIAL_ALLOCATION "Initial Alloc",
      LIMIT_VALUE "Limit"
from v$resource_limit
/

/*
doc

WorkLoad Breakdown

    Purpose - ¼¼¼Çº°·Î ¼­ºñ½º ½Ã°£°ú Wait½Ã°£ÀÇ ºñÀ² ¹× ¼­ºñ½º½Ã°£ÀÇ ±¸¼ºÇöȲÀ» Á¡°ËÇÑ´Ù.

    Description - ¼¼¼Çº°·Î ¼Ò¸ðÇÑ Àüü CPU Time°ú ´ëºñÇÏ¿© Idle Event¸¦ Á¦¿ÜÇÑ
      Wait Event¿¡ ´ëÇÑ Wait TimeÀÇ ºñÀ²À» º¸¿©ÁØ´Ù. ¶ÇÇÑ CPU TimeÀ» Parse Time,
      Recursive Time, Other TimeÀ¸·Î ±¸ºÐÇÏ¿© °¢°¢ÀÇ ÀÛ¾÷¿¡ ¼Ò¸ðµÈ CPU Time ºñÀ²À» º¸¿©ÁØ´Ù.
      [Service Time], [Wait Time]Àº cs(Centi Second, 1/100ÃÊ) ´ÜÀ§ÀÌ´Ù.

    Guide - ¼­ºñ½º ½Ã°£(CPU TIme)¿¡ ´ëÇÑ Wait ½Ã°£ÀÇ ºñÀ²Àº ½Ã½ºÅÛÀÇ Æ¯¼º¿¡ ¸¹ÀÌ Á¿ìµÇ¹Ç·Î
            ¸í¹éÇÑ ±âÁØÀº ¾øÀ¸¸ç, ´Ù¸¸ ¼­ºñ½º ½Ã°£¿¡ ºñÇØ Wait ½Ã°£ÀÌ Áö³ªÄ¡°Ô ¸¹´Ù¸é ¾î¶²
            Wait Event¿¡  ´ëÇÏ¿© Wait°¡ ¸¹ÀÌ ¹ß»ýÇÏ¿´´ÂÁö Á¡°ËÇÏ¿© ÇØ´ç Wait Event¸¦ ÃÖ¼ÒÈ­ÇÏ´Â
              ¹æ¾ÈÀ» ã¾Æ¾ß ÇÑ´Ù.  ¶ÇÇÑ CPU TIme °¡¿îµ¥ Parse TimeÀÌ Â÷ÁöÇÏ´Â ºñÀ²ÀÌ ³ô´Ù¸é
              (ÀϹÝÀûÀ¸·Î 20%ÀÌ»ó) Literal SQLÀÌ  ¸¹ÀÌ ¼öÇàµÇ°í ÀÖ´Ù°í ÆÇ´ÜÇÒ ¼ö ÀÖÀ¸¹Ç·Î
              ÇØ´ç ¼¼¼Ç¿¡¼­ ¼öÇàµÇ´Â SQL¿¡ ´ëÇÑ Æ©´×À» ¼öÇàÇÒ ÇÊ¿ä°¡ ÀÖ´Ù.
              [Service(Other)]´Â Free Buffer¸¦ ã°í, LockingÇÏ°í, ´ë»ó ·¹Äڵ带 FetchÇÏ´Â
              µîÀÇ ÀÛ¾÷¿¡ »ç¿ëµÇ´Â CPU¼Ò¸ð·®À¸·Î¼­ ÀϹÝÀûÀ¸·Î CPU TimeÀÇ 80% ÀÌ»óÀ» À¯ÁöÇؾß
              Çϸç, ÀÌ ºñÀ²ÀÌ ³·À¸¸é SQLÀ» Á¡°ËÇÑ´Ù.
#
*/

select cpu.sid, cpu.t_cpu "Service Time", wait.t_wait "Wait Time",
        round(decode(cpu.t_cpu,0,0, (wait.t_wait/cpu.t_cpu )*100),2) "Wait/Service(%%)",
        round(decode(cpu.t_cpu,0,0, (cpu.p_cpu/cpu.t_cpu)*100),2) "Service(Parse)%%",
        round(decode(cpu.t_cpu,0,0, (cpu.r_cpu/cpu.t_cpu)*100),2) "Service(Recursive)%%",
        round(decode(cpu.t_cpu,0,0, ((cpu.t_cpu-cpu.r_cpu-cpu.p_cpu)/cpu.t_cpu)*100),2) "Service(Other)%%"
from
        (select /*+ ordered */ sid, sum(decode(n.name,'CPU used by this session', value)) t_cpu,
                sum(decode(n.name,'parse time cpu', value)) p_cpu,
                sum(decode(n.name,'recursive cpu usage', value)) r_cpu
            from v$statname n, v$sesstat s
          where s.statistic# = n.statistic#
              and n.name in ( 'parse time cpu', 'CPU used by this session','recursive cpu usage')
          group by sid ) cpu,
        (select /*+ ordered */ sid, sum(time_waited) t_wait
              from  v$session_event
            where  event not like '%SQL*Net%'
              and event not like '%pipe get%'
              and event not like '%rdbms ipc message'
              and event not like '%smon timer%'
              and event not like '%pmon timer%'
        group  by sid ) wait
where cpu.sid = wait.sid
  and cpu.t_cpu+wait.t_wait > 0
/

/*
doc
~~~ SGA ~~~

Buffer Cache Hit Ratio

    Purpose - µ¥ÀÌÅͺ£À̽º ¹öÆÛij½¬ÀÇ ÀûÁß·üÀ» Á¡°ËÇÑ´Ù.

    Description - Buffer CacheÀÇ ±âº»ÀûÀÎ ±â´ÉÀº ¿©·¯ ÇÁ·Î¼¼½º¿¡ ÀÇÇØ °øÅëÀ¸·Î ÀÚÁÖ ¾×¼¼½º
          µÇ´Â µ¥ÀÌÅͺ£À̽º ºí·ÏÀ» ¸Þ¸ð¸®¿¡ ij½¬ÇÏ¿© ¹°¸®ÀûÀÎ µð½ºÅ© IO¸¦ ÃÖ¼ÒÈ­ÇÔÀ¸·Î½á ´õ
          ºü¸¥ ¾×¼¼½º ¼Óµµ¸¦ Á¦°øÇϱâ À§ÇÑ °ÍÀÌ´Ù. ¹öÆÛij½¬ÀÇ ÀûÁß·üÀ̶õ ¾ÖÇø®Ä³À̼ÇÀÌ
          ¾×¼¼½ºÇÑ ¸Þ¸ð¸® ºí·° °¡¿îµ¥ ÀÌ¹Ì Ä³½¬°¡ µÇ¾îÀÖ¾î ¹°¸®Àû IO¾øÀÌ ¾×¼¼½º ÇÒ ¼ö ÀÖ¾ú´ø
          ºí·°ÀÇ ºñÀ²À» ³ªÅ¸³½´Ù. ¸¸¾à µ¥ÀÌÅͺ£À̽º ¹öÆÛÀÇ ÀûÁß·üÀÌ ±ÇÀå°ª ¹Ì¸¸ÀÏ °æ¿ì¿¡´Â
          ÇÒ´çµÈ ¹öÆÛ Ä³½¬ÀÇ Å©±â°¡ ³Ê¹« Àû°Å³ª, ¶Ç´Â Áö³ªÄ¡°Ô ¸¹Àº I/O¸¦ À¯¹ßÇÏ´Â ¾ÖÇø®ÄÉÀ̼ÇÀÌ
            Á¸ÀçÇÑ´Ù´Â °ÍÀ» ÀǹÌÇÑ´Ù.
     
    Criteria - 90.0 % Minimum

    Guide - µ¥ÀÌÅͺ£À̽º ¹öÆÛij½¬ÀÇ ÀûÁß·üÀº OLTP, DSS, DWµî µ¥ÀÌÅͺ£À̽º¸¦ »ç¿ëÇÏ´Â ¾ÖÇø®ÄÉÀ̼ÇÀÇ
          Ư¼º¿¡ µû¶ó ±ÇÀå°ªÀÌ ´Ù¸£´Ù. ÀϹÝÀûÀ¸·Î, OLTP½Ã½ºÅÛÀº 90%ÀÌ»óÀº µÇ¾î¾ß ÇÏ°í DSS, DW
          ½Ã½ºÅÛÀº 80~85%ÀÌ»óÀ̸é ÁÁ´Ù°í ÇÒ ¼ö ÀÖÀ¸³ª, ¼ø¼öÇÏ°Ô ¹èÄ¡(Batch) 󸮾÷¹« À§ÁÖÀÇ
          ½Ã½ºÅÛÀÎ °æ¿ì´Â 50%¸¦ ¹Øµ¹´õ¶óµµ ±× ÀÚü·Î ¹®Á¦°¡ µÈ´Ù°í ´ÜÁ¤ÇÒ ¼ø ¾ø´Ù.
          µ¥ÀÌÅͺ£À̽º ¹öÆÛij½¬ÀÇ ÀûÁß·üÀÌ ±âÁØ°ªº¸´Ù ³·Àº °æ¿ì¿¡´Â ÃʱâÈ­ ÆĶó¹ÌÅÍ db_block_buffersÀÇ
          °ªÀ» ´Ã·Á ¹öÆÛij½¬ÀÇ Å©±â¸¦ Áõ°¡½Ãų ¼ö ÀÖ´Ù. À̶§ O/S»ó¿¡ ¸Þ¸ð¸®°¡ ¿©À¯ ÀÖ´ÂÁö È®ÀÎ ÇÏ¿©¾ß
          ÇÏ¸ç ¸Þ¸ð¸® ºÎÁ·À¸·Î Paging, SwappingÀÌ ¹ß»ýÇÏÁö ¾Ê´Â Çѵµ³»¿¡¼­ Áõ°¡½ÃÄÑ ÁÖ¾î¾ß ÇÑ´Ù.
          ±×·¯³ª µð½ºÅ©»óÀÇ ¸ðµç µ¥ÀÌÅÍºí·°À» ij½¬½ÃÅ°´Â °ÍÀº Çö½ÇÀûÀ¸·Î ºÒ°¡´ÉÇϹǷΠÀϹÝÀûÀ¸·Î
          ¹öÆÛij½¬ÀÇ Áõ°¡°¡ ÃÖ¼±ÀÇ ÇØ°áÃ¥ÀÌ µÉ ¼ö´Â ¾ø´Ù. ƯÈ÷, ´Ù·®ÀÇ µð½ºÅ© ºí·ÏÀ» ºó¹øÈ÷
          Full ScanÇÏ´Â ¾ÖÇø®ÄÉÀ̼ÇÀÌ Á¸ÀçÇÑ´Ù¸é ÀûÁß·üÀ» ³ôÀº ¼öÁØÀ¸·Î À¯ÁöÇÏ´Â °ÍÀº ºÒ°¡´ÉÇϹǷÎ
          ¾×¼¼½ºÆÐÅÏÀÌ ºñÈ¿À²ÀûÀÎ ¾ÖÇø®ÄÉÀ̼ÇÀ» ÃßÃâÇÏ¿© Áö¼ÓÀûÀÎ Æ©´×À» ¼öÇàÇØ ÁÖ¾î¾ß ÇÑ´Ù.
#
*/

select  to_char(sysdate,'yyyy/mm/dd HH24:MI:SS') "Time",
          a.value+b.value "Logical Reads",
          c.value "Physical Reads",
          round((1 - (c.value/(a.value+b.value)))*100, 3) "Hit Ratio"
from    v$sysstat a, v$sysstat b, v$sysstat c
where  a.name = 'db block gets'
      and      b.name = 'consistent gets'
      and      c.name = 'physical reads'
/

/*
doc
Library Cache Hit Ratio (summary)

    Purpose ¶óÀ̺귯¸® ij½¬ ÀüüÀÇ ÀûÁß·üÀ» Á¡°ËÇÑ´Ù.

    Description - ¿À¶óŬÀº SQL ÆÄ½Ì ÀÛ¾÷¿¡ µû¸¥ CPU¸¦ ºñ·ÔÇÑ ÀÚ¿ø»ç¿ëÀ» ÃÖ¼ÒÈ­ÇÏ°í,
      SQLÀÇ ½ÇÇà½Ã°£ÀÇ ´ÜÃà°ú ¸Þ¸ð¸® Àý¾à µîÀÇ ¸ñÀûÀ» À§ÇÏ¿© SGA °¡¿îµ¥ ÀϺÎÀÎ
      Shared Pool³»¿¡ SQLÀ» °øÀ¯ÇÏ°í Àִµ¥, ÀÌ ¿µ¿ªÀ» ¶óÀ̺귯¸® ij½¬¶ó°í ÇÑ´Ù.
      ¿©±â¼­ ¶óÀ̺귯¸® ij½¬ÀÇ ÀûÁß·üÀº PinsȽ¼ö °¡¿îµ¥ ReloadsȽ¼ö¸¦ Á¦¿ÜÇÑ ºñÀ²·Î
      °è»êµÇ¸ç, À̶§ Pins´Â ij½¬³»ÀÇ SQL Ä¿¼­ÀÇ ½ÇÇàȽ¼ö, Reloads´Â ij½¬¿¡ Á¸ÀçÇÏ´ø
      SQLÄ¿¼­ Á¤º¸°¡ ¸Þ¸ð¸® ¹ÛÀ¸·Î ageoutµÇ°Å³ª invalidateµÇ¾ú´Ù°¡ ´Ù½Ã LoadµÈ Ƚ¼ö¸¦
      ÀǹÌÇÑ´Ù. ¿ä¾àÇϸé, ¶óÀ̺귯¸® ij½¬ÀÇ ÀûÁß·üÀ̶õ ¼öÇàÇÏ·Á´Â SQL Ä¿¼­ Á¤º¸°¡
      (ageoutµÇÁö ¾Ê°í) ¶óÀ̺귯¸® ij½¬³»¿¡ Á¸ÀçÇÒ È®·üÀ» ÀǹÌÇÑ´Ù.
     
    Criteria - 99.0 % Minimum

    Guide - ¶óÀ̺귯¸® ij½¬ÀÇ ÀûÁß·üÀº 99% ÀÌ»óÀ» À¯ÁöÇÒ °ÍÀ» ±ÇÀåÇÑ´Ù. ÀÌ °ªÀÌ ±ÇÀå°ªº¸´Ù
            ³·À» °æ¿ì¿¡´Â ÃʱâÈ­ ÆĶó¹ÌÅÍ shared_pool_size¸¦ »ç¿ëÇÏ¿© Shared PoolÀÇ Å©±â¸¦
            Áõ°¡½ÃÄÑ °³¼±½Ãų ¼ö ÀÖ´Ù. ´õ¿í È¿°úÀûÀÎ °ÍÀº, »ç¿ëµÇ´Â SQLÀÇ °øÀ¯ Á¤µµ¸¦ ³ôÀ̱â
            À§ÇØ Literal SQL(Á¶°ÇÀý¿¡ »ó¼ö°ªÀ» »ç¿ëÇÏ´Â SQL)À» ¹ÙÀÎµå º¯¼ö¸¦ »ç¿ëÇϵµ·Ï ¼öÁ¤ÇØ
            ÁÖ´Â °ÍÀÌ´Ù.
#
*/

select  to_char(sysdate,'yyyy/mm/dd hh24:mi:ss') "Time",
round((1-(sum(reloads)/sum(pins)))*100, 3) "Hit Ratio(Pins-Reloads)"
from    v$librarycache
/

/*
doc

Library Cache Hit Ratio (Namespace)

    Purpose - Namespaceº° ¶óÀ̺귯¸® ij½¬ÀÇ ÀûÁß·üÀ» Á¡°ËÇÑ´Ù.

    Description - [Gets]´Â Library Cache LockÀ» ¿äûÇÑ È½¼öÀ̸ç, [Pins]´Â Library Cache PinÀ»
          ¿äûÇÑ È½¼öÀÌ´Ù. Library Cache LockÀº ¶óÀ̺귯¸® ij½¬³»¿¡¼­ ¿øÇÏ´Â ¿ÀºêÁ§Æ®
          (¶Ç´Â SQLÄ¿¼­)¸¦ ã¾Æ°¡´Â °úÁ¤¿¡¼­ ¿äûµÇ¸ç Library Cache PinÀº ã¾Æ³½ ¿ÀºêÁ§Æ®
          (¶Ç´Â SQLÄ¿¼­)ÀÇ ³»¿ëÀ» Á¢±ÙÇϰųª º¯°æÇϱâ À§ÇØ ¿äûµÈ´Ù. LockÀº ¶óÀ̺귯¸® ij½¬
          ¿ÀºêÁ§Æ®ÀÇ ÇÚµéÀ», PinÀº ¶óÀ̺귯¸® ij½¬ ¿ÀºêÁ§Æ®ÀÇ µ¥ÀÌÅÍ¿µ¿ª(heap)À» º¸È£ÇÑ´Ù.
          PinÀº LockÀ» ȹµæÇÑ ÈÄ È¹µæÇÒ ¼ö ÀÖÀ¸¸ç »ó´ëÀûÀ¸·Î ªÀº±â°£ Áö¼ÓµÈ´Ù. LockÀ» Àâ°íÀÖ´Â
          µ¿¾ÈÀº ´Ù¸¥ ÇÁ·Î¼¼½º°¡ ÇØ´ç ¶óÀ̺귯¸® ij½¬ ¿ÀºêÁ§Æ®¿¡ Á¢±ÙÇÒ ¼ö ¾ø°í, pinÀ» Àâ°í
          ÀÖ´Â µ¿¾ÈÀº ÇØ´ç ¿ÀºêÁ§Æ®´Â ageoutµÇÁö ¾Ê´Â´Ù. [Invalidations]´Â ¿ÀºêÁ§Æ®ÀÇ ±¸Á¶°¡
          º¯°æµÇ¾î ¿ÀºêÁ§Æ® ¶Ç´Â SQLÄ¿¼­°¡ InvalidµÇ°Å³ª SQLÄ¿¼­°¡ ÂüÁ¶ÇÏ´Â ¿ÀºêÁ§Æ®¿¡
          Analzye°¡ ¼öÇàµÇ¾î InvalidµÈ Ƚ¼öÀÌ´Ù. 
    Criteria -  90.0 % Minimum
    Guide  - ¸ðµç Namespaceº° ÀûÁß·üÀÌ 90%ÀÌ»óÀ» À¯ÁöÇÒ °ÍÀ» ±ÇÀåÇÑ´Ù. ƯÈ÷, SQL AREA namespaceÀÇ
          ÀûÁß·üÀÌ ³·À» °æ¿ì¿¡´Â ºó¹øÈ÷ »ç¿ëµÇ´Â SQL °¡¿îµ¥ Literal SQLÀÌ ÀÖ´ÂÁö Á¶»çÇÏ¿© ¹ÙÀÎµå º¯¼ö¸¦
          »ç¿ëÇϵµ·Ï ¼öÁ¤ÇÏ¿©ÁÖ´Â °ÍÀÌ ÁÁ´Ù.
#
*/

select namespace "Namespace",
gets "Gets",  round(gethitratio*100,3) "GetHit Ratio",
pins "Pins",  round(pinhitratio*100,3) "PinHit Ratio",
invalidations "Invalidations",
decode(pins,0,-1,round((1-reloads/pins)*100, 3)) "Hit Ratio(Pins-Reloads)"
from v$librarycache
/

/*
doc
Dictionary Cache Hit Ratio (summary)

    Purpose - µñ¼Å³Ê¸® ij½¬ ÀüüÀÇ ÀûÁß·üÀ» Á¡°ËÇÑ´Ù.

    Description - µñ¼Å³Ê¸® ij½¬´Â µ¥ÀÌÅÍ µñ¼Å³Ê¸® Á¤º¸¸¦ ij½¬½ÃÄѵδ ¿µ¿ªÀ¸·Î Shared Pool¿¡¼­
        ÇÒ´çÇÑ´Ù. µñ¼Å³Ê¸® ij½¬ÀÇ Å©±â¸¦ »ç¿ëÀÚ°¡ µû·Î ÁöÁ¤ÇÒ ¼ö´Â ¾øÀ¸¸ç, ¿À¶óŬÀº Shared Pool
        °¡¿îµ¥ µñ¼Å³Ê¸® ij½¬¸¦ ¿ì¼±ÀûÀ¸·Î ÇÒ´çÇϹǷΠ¶óÀ̺귯¸® ij½¬ÀÇ ÀûÁß·üÀÌ ¾çÈ£ÇÏ´Ù¸é
        ´ç¿¬È÷ µñ¼Å³Ê¸® ij½¬ÀÇ ÀûÁß·ü ¶ÇÇÑ ¾çÈ£ÇÒ °ÍÀÌ´Ù. ÇÑ°¡Áö °í·ÁÇÒ Á¡Àº, ÀνºÅϽº°¡ ±âµ¿µÈ
        Áö ¾ó¸¶°£ÀÇ ½Ã°£ÀÌ Áö³­ ÈÄ¿¡¾ß ÀÌ °ªÀÌ Àǹ̰¡ ÀÖ´Ù´Â Á¡ÀÌ´Ù.
       
    Criteria - 90.0 % Minimum
         
    Guide - Dictionary CacheÀÇ ÀûÁß·üÀº 90%ÀÌ»óÀ» À¯ÁöÇÒ °ÍÀ» ±ÇÀåÇÑ´Ù. ÀûÁß·üÀÌ ±âÁØ°ª ÀÌÇÏÀÏ
        °æ¿ì¿¡´Â ÃʱâÈ­ ÆĶó¹ÌÅÍ shared_pool_size¸¦ º¯°æÇÏ¿© Shared PoolÀÇ Å©±â¸¦ Áõ°¡½ÃÄÑ
        ÀûÁß·üÀ» ³ôÀÏ ¼ö ÀÖ´Ù. 
#
*/

select  to_char(sysdate,'yyyy/mm/dd hh24:mi:ss') "Time",
round((1-sum(getmisses)/sum(gets))*100, 3) "Hit Ratio"
from    v$rowcache
/

/*
doc
Dictionary Cache Hit Ratio (Parameter)

    Purpose - Parameterº° µñ¼Å³Ê¸® ij½¬ÀÇ ÀûÁß·üÀ» Á¡°ËÇÑ´Ù.

    Description µñ¼Å³Ê¸® ij½¬³»¿¡¼­ ¿ÀºêÁ§Æ®º°·Î ÀûÁß·üÀ» Á¡°ËÇÏ°í, ¹®Á¦°¡ µÇ´Â
          ÆĶó¹ÌÅÍ Ç׸ñ¿¡ ´ëÇÏ¿© ¿øÀκм® ¹× Á¶Ä¡¸¦ ¼öÇàÇÑ´Ù.

    Criteria - 90.0 % Minimum

    Guide -  ÆĶó¹ÌÅͺ° ÀûÁß·üÀÌ °¢°¢ 90%ÀÌ»óÀ» À¯ÁöÇÒ °ÍÀ» ±ÇÀåÇÑ´Ù. À¯³­È÷ ÀûÁß·üÀÌ ³·Àº ÆĶó¹ÌÅÍ
            Ç׸ñ¿¡ ´ëÇÏ¿© °¢°¢ÀÇ Æ¯¼º¿¡ µû¶ó ¿øÀÎÀ» ÆÇ´ÜÇÏ¿© º¼ ÇÊ¿ä°¡ ÀÖ´Ù. ¿¹¸¦ µé¾î,
            dc_free_extents, dc_used_extentsÀÇ ÀûÁß·üÀÌ ³·´Ù¸é ÀúÀå°ø°£ÀÇ ½Ç½Ã°£ ÇÒ´çÀÌ
            Àæ´Ù´Â °ÍÀ» ÀǹÌÇϹǷΠ¿ÀºêÁ§Æ®ÀÇ ÀúÀå¿É¼ÇÀ» °ËÅäÇϰųª, Locally Managed tablespaceÀÇ
            ¿î¿µÀ» °ËÅäÇغ¼ ¼ö ÀÖÀ¸¸ç, dc_sequence°¡ ¹®Á¦µÇ´Â °æ¿ì´Â SequenceÀÇ Cache »çÀÌÁ Áõ°¡
            ½ÃÅ°´Â ¹æ¾ÈÀ» °ËÅäÇغ¼ ¼ö ÀÖ°í, dc_synonymÀÇ ÀûÁß·üÀÌ ºñÁ¤»óÀûÀ¸·Î ³·´Ù¸é ¸¹Àº À¯Àú°¡
            °¢ÀÚÀÇ private SynonymÀ» »ç¿ëÇÏ°í ÀÖÁö ¾ÊÀºÁö Á¡°ËÇغ¼ ÇÊ¿ä°¡ ÀÖ´Ù.     
#
*/
       
SELECT parameter "Parameter",
        sum(gets) "Gets",
        sum(getmisses) "GetMisses" ,
        decode(sum(gets), 0, -1, round((1-sum(getmisses)/sum(gets))*100, 3)) "Hit Ratio"
FROM v$rowcache
GROUP BY parameter
/

/*
doc
Shared Pool Free Space

    Purpose - Shared Pool³»ÀÇ Free Memory Å©±â¸¦ È®ÀÎÇÑ´Ù

    Description - Shared PoolÀº ¶óÀ̺귯Ű ij½¬, µñ¼Å³Ê¸® ij½¬, Large Pool µîÀ¸·Î ±¸¼ºµÈ´Ù. ¿©±â¿¡¼­
          ¾Ë ¼ö ÀÖµíÀÌ Shared PoolÀº ±âº»ÀûÀ¸·Î ij½¬¸¦ À§ÇÑ ¿µ¿ªÀ̹ǷΠ¿©À¯°ø°£ÀÌ ³²¾ÆÀÖ´Â ÇÑ ±âÁ¸
          ¿ÀºêÁ§Æ®ÀÇ ageout ¾øÀÌ °è¼Ó ¼Ò¸ðÇÏ·Á´Â ¼Ó¼ºÀÌ ÀÖ´Ù. µû¶ó¼­ ¶óÀ̺귯¸® ij½¬³ª µñ¼Å³Ê¸®
          ij½¬ÀÇ ÀûÁß·üÀÌ ¾çÈ£ÇÏ´Ù¸é ÀϹÝÀûÀÎ ¿î¿µ½Ã°£´ë¿¡ free memory Å©±â°¡ ³·Àº »óŸ¦ À¯ÁöÇÏ´Â
          °ÍÀº Á¤»óÀÌ´Ù. ¿ÀÈ÷·Á, Ç×»ó Å« free memory°¡ ³²¾Æ ÀÖ´Ù¸é Shared PoolÀÌ ºÒÇÊ¿äÇÏ°Ô Å©°Ô
          ¼³Á¤µÇ¾î ÀÖ´Ù´Â °ÍÀ» ÀǹÌÇϸç, ÀϽÃÀûÀ¸·Î °©ÀÚ±â free memory Å©±â°¡ Áõ°¡ÇÏ´Â °æ¿ì´Â
          FragmentationÀÌ ¸¹ÀÌ ¹ß»ýÇÏ¿© ¸¹Àº ¿ÀºêÁ§Æ®°¡ ÇѲ¨¹ø¿¡ flushµÈ °ÍÀ» ÀǹÌÇϹǷΠ¹®Á¦¸¦
          °Þ°í ÀÖ´Ù´Â Áõ»óÀÏ ¼ö ÀÖ´Ù.
          ÀϹÝÀûÀ¸·Î Shared pool¿¡¼­ ¹®Á¦°¡ µÇ´Â °ÍÀº ½Ã°£ÀÌ Áö³²¿¡ µû¶ó ¸Þ¸ð¸® ¿µ¿ªÀÌ ÀÛÀº
          Á¶°¢À¸·Î ºÐÇÒ(Fragmentation)µÇ¾î »çÀÌÁî°¡ Å« ¿ÀºêÁ§Æ®ÀÇ ·Îµå¸¦ À§ÇÑ memoryÇÒ´ç¿¡ ¾î·Á¿òÀ»
          °Þ°Å³ª ½ÉÇÏ°Ô´Â ÇÊ¿äÇÑ ¿¬¼ÓµÈ ¸Þ¸ð¸® °ø°£ÀÇ È®º¸¿¡ ½ÇÆÐÇÏ¿© ora-4031¿¡·¯°¡ ³ª´Â °æ¿ìÀÌ´Ù.
          ƯÈ÷, MTS·Î ¿î¿µµÇ´Â °æ¿ì UGA ¿µ¿ªÀÌ Shared Pool¿¡ ÇÒ´çµÇ¹Ç·Î FragmentatioÀÌ ¹ß»ýÇÒ
          °¡´É¼ºÀÌ ´õ ³ô´Ù. ¿À¶óŬÀº Å©±â°¡ Å« ¿ÀºêÁ§Æ®(5000 bytes ÀÌ»ó)µéÀ» À§Çؼ­ ±âº»ÀûÀ¸·Î
          shared poolÀÇ 5% Á¤µµ¸¦ µû·Î È®º¸Çؼ­ °ü¸®Çϴµ¥, ÀÌ Å©±â´Â shared_pool_reserved_size
          ÆĶó¹ÌÅÍ·Î Á¶Á¤ÇÒ ¼ö ÀÖ´Ù.

    Guide - Shared Pool ¸Þ¸ð¸®ÀÇ Á¶°¢È­¸¦ ¿¹¹æÇϱâ À§ÇÑ Á¶Ä¡·Î´Â ´ÙÀ½°ú °°Àº ¹æ¹ýÀÌ ÀÖ´Ù.
        - »çÀÌÁî°¡ Å« PL/SQL ºí·°ÀÇ »ç¿ëÀ» ÀÚÁ¦ÇÑ´Ù.
        - ºÒ°¡ÇÇÇÏ°Ô »çÀÌÁî°¡ Å« PL/SQL ¿ÀºêÁ§Æ®´Â DBMS_SHARED_POOL.KEEPÀ» »ç¿ëÇÏ¿© KEEPÇÑ´Ù.
        -  Literal SQLÀ» ¹ÙÀÎµå º¯¼ö¸¦ »ç¿ëÇϵµ·Ï ¼öÁ¤ÇØ ÁØ´Ù.
        - shared_pool_reserved_sizeÀÇ Áõ°¡¸¦ °í·ÁÇÑ´Ù.
        - MTSÀÇ °æ¿ì ¼¼¼Çº°·Î Áö³ªÄ¡°Ô ¸¹Àº UGA¿µ¿ªÀ» ÇÒ´çÇÏÁö ¾Êµµ·Ï ÁÖÀÇÇÏ¿© ¾ÖÇø®ÄÉÀ̼ÇÀ» ÀÛ¼ºÇÑ´Ù.

#
*/

col "Shared Pool Reserved(MB)" format a40

select  s.total "Shared Pool Total(MB)",
        s.free - r.r_free "Shared Pool Free(MB)",
        'Free : ' || r.r_free || ',      Used : ' ||r.r_used "Shared Pool Reserved(MB)",
        s.other - r.r_used  "Shared Pool Other(MB)"
        from (select round(sum(bytes/1024/1024),2) total,
        round(sum(decode(name, 'free memory', bytes))/1024/1024,2) free,
        round(sum(decode(name, 'free memory',null, bytes))/1024/1024,2) other
        from  v$sgastat
        where  pool = 'shared pool' ) s,
        (select round(nvl(sum(free_space),0)/1024/1024,2) r_free,
        round(nvl(sum(used_space),0)/1024/1024,2) r_used
from v$shared_pool_reserved ) r
/

/*
doc
Redo Buffer Contention

    Purpose - Redo Log Buffer¿¡ ´ëÇÑ °æÇÕ»óŸ¦ È®ÀÎÇÑ´Ù.
   
    Description - Redo Buffer Space Wait(%)Àº redo entry°¡¿îµ¥ log buffer space¸¦ ÇÒ´ç¹Þ±â
          À§ÇØ WaitÇÑ ºñÀ²À» ÀǹÌÇϸç, redo space requests´Â ÇØ´ç Wait eventÀÇ ¹ß»ýȽ¼öÀÌ´Ù.
          Redo Log Buffer´Â ÀϹÝÀûÀ¸·Î Å« ¹®Á¦¸¦ À¯¹ßÇÏ´Â ¿µ¿ªÀº ¾Æ´Ï³ª, °æÇÕÀÌ Á¸ÀçÇÒ °æ¿ì
          µ¥ÀÌÅͺ£À̽º ¼º´É ÀüüÀÇ º´¸ñ±¸°£À¸·Î ÀÛ¿ëÇÒ ¼ö ÀÖ´Ù. Space Request À̺¥Æ®¸¦ °¨¼Ò½ÃÅ°±â
          À§Çؼ­´Â redo log buffer¸¦ ´Ã¸®°Å³ª, »ý»êµÇ´Â RedoÀÇ ¾çÀ» ÁÙÀ̰ųª LGWRÀÇ ÀÛ¾÷È¿À²À»
          ³ô¿©ÁÖ¾î¾ß ÇÑ´Ù.

    Guide - Redo Buffer Space Wait Ratio¿Í Redo Log Space Request°¡ 0¿¡ °¡±î¿ö¾ß Çϸç ÀÌ ¼öÄ¡°¡
            ºñ±³Àû ³ôÀº °ªÀÌ°í ¿¬¼ÓÀûÀ¸·Î Áõ°¡Çϸé init.oraÀÇ log_buffers¸¦ Áõ°¡½ÃÅ°´Â °ÍÀ» °í·ÁÇÒ ¼ö ÀÖ´Ù.
            Log_buffersÀÇ ÀûÀýÇÑ Å©±â´Â 1M ~ 10M »çÀÌ·Î ÁöÁ¤ÇÑ´Ù.
#
*/

select round(sum(decode(name, 'redo buffer allocation retries', value))/sum(decode(name, 'redo entries', value)),5)
      "Redo Buffer Space Wait(%%)",
      sum(decode(name, 'redo log space requests', value)) "Redo Space Reqeusts"
from v$sysstat
/

/*
doc
Latch Hit Ratio

    Purpose - SGA³»ÀÇ ¸ðµç Latch¿¡ ´ëÇÑ Hit Ratio¸¦ È®ÀÎÇÑ´Ù.

    Description - (I)Gets, (I)Misses Ç׸ñÀº °¢°¢ Gets(¶Ç´Â Immediate gets)¿Í Misses
        (¶Ç´Â Immediate misses) °ªÀ» ÀǹÌÇϸç,Gets¿Í Immediate gets °¡¿îµ¥ Å« °ªÀ» º¸¿©ÁØ´Ù.
        Gets´Â Willing-to-wait ¸ðµå·Î ¿äûµÈ °æ¿ì, Immediate gets´Â No-Wait ¸ðµå·Î ¿äûµÈ
        °æ¿ìÀε¥, Willing-to-Wait ¸ðµå´Â latchȹµæ¿¡ ½ÇÆÐÇÏ´Â °æ¿ì  spin°ú sleepÀ» Çϸ鼭 ȹµæ¿¡
        ¼º°øÇÒ ¶§±îÁö Àç½ÃµµÇÏ´Â °ÍÀ̸ç, No-Wait ¸ðµå´Â ¿øÇÏ´Â latch ȹµæ¿¡  ½ÇÆÐÇÏ´Â °æ¿ì ÇØ´ç
        latch¸¦ À§ÇØ WaitÇÏÁö ¾Ê´Â´Ù. redo copy latchó·³ µ¿ÀÏÇÑ ±â´ÉÀÇ latch°¡ ¿©·¯  °³ÀÎ °æ¿ì,
        ¶Ç´Â deadlockÀ» ÇÇÇϱâ À§ÇØ No-Wait ¸ðµå°¡ »ç¿ëµÈ´Ù. redo copy latch¸¦ Á¦¿ÜÇÏ¸é ¸ðµç
        latchµéÀº ´ëºÎºÐ Willing to Wait ¸ðµå·Î ¿äûµÈ´Ù. 

    Criteria - 98.0 % Minimum

    Guide - ¸ðµç LatchÀÇ Hit Ratio°¡ 98% ÀÌ»óÀÌ µÇ¾î¾ß ÇÑ´Ù. °¢°¢ÀÇ Latchº°·Î Hit Ratio°¡ ÁÁÁö ¾ÊÀº °ÍÀº
        °¢°¢ÀÇ Latch¿¡ ´ëÇÑ Resource¸¦ ´Ã·ÁÁְųª, ÇØ´ç Latch¸¦ ¸¹ÀÌ »ç¿ëÇÏ´Â ApplicationÀÇ »ç¿ë Á¤µµ¸¦ °¨¼Ò½ÃŲ´Ù.

#
*/

select name "Name",
        decode(sign(gets-immediate_gets), 1, gets, immediate_gets) "(I)Gets",
        decode(sign(gets-immediate_gets), 1, misses, immediate_misses) "(I)Misses",
        sleeps "Sleeps",
        decode(sign(gets-immediate_gets), 1, round(decode(gets,0,-1,(1-misses/gets) * 100),3),
        round(decode(immediate_gets+immediate_misses,0,-1,
        (1- immediate_misses/ (immediate_gets+immediate_misses)) * 100), 3 ))    "Hit Ratio"
from  v$latch
where decode(sign(gets-immediate_gets), 1, gets, immediate_gets) > 0
order by 4 desc, 2 desc
/

/*
doc
Session Cursor Cache Hit Ratio

    Purpose - Àüü SQL Call °¡¿îµ¥ Session Cursor CacheÀÇ Hit Ratio¸¦ È®ÀÎÇÑ´Ù.

    Description - µ¿ÀÏÇÑ Ä¿¼­·Î 3¹øÀÌ»ó ÆĽ̵Ǹé ÇØ´ç SQLÀº Session cache¿¡ µî·ÏµÇ¾î ÀÌÈÄ¿¡ µ¿ÀÏ ¼¼¼Ç¿¡¼­
        ¿äûµÇ¸é º°µµÀÇ parsing(soft,hard parse)¾øÀÌ ¹Ù·Î Àç»ç¿ëµÈ´Ù. ÀÌ¿Í °°Àº session cache ±â´ÉÀ»
        »ç¿ëÇϱâ À§Çؼ­´Â ÃʱâÈ­ ÆĶó¹ÌÅÍ session_cached_cursors°¡ ¼³Á¤µÇ¾î¾ß Çϸç ÀϹÝÀûÀ¸·Î 50ÀÌ»óÀÇ
        °ªÀ¸·Î ¼³Á¤ÇÏ´Â °ÍÀÌ ÁÁ´Ù. ¸ðµç SQL callÀº ¼¼¼Ç ij½¬·ÎºÎÅÍ Àç»ç¿ë(
        session cursor cache hit, no parse), ¶óÀ̺귯¸® ij½¬·ÎºÎÅÍ Àç»ç¿ë(soft parse),
        »õ·Î ÆĽÌÇÏ¿© »ç¿ë(hard parse)ÀÇ ¼¼°¡Áö °¡¿îµ¥ ÇϳªÀÌ´Ù. 
       
    Criteria - 30.0 % Minimum

    Guide - ÀϹÝÀûÀ¸·Î ÀûÁß·üÀÌ 30% ÀÌ»óÀ¸·Î À¯ÁöµÇ´Â °ÍÀÌ ¹Ù¶÷Á÷ÇÏ´Ù. ±âÁØ°ª ÀÌÇÏÀÏ °æ¿ì¿¡´Â init.oraÀÇ
          vsession_cached_cursorsÀÇ °ªÀ» ´Ã·Á ÁØ´Ù. º¸ÅëÀÇ °æ¿ì Å©¸é Ŭ ¼ö·Ï ÁÁÀ¸³ª 128ÀÌÇÏ·Î ÁöÁ¤ÇÏ¿© Æ©´×ÇÑ´Ù.
#
*/

select
      round(100 * (calls - sess - hard) / calls, 3)  "Soft Parses(%%)",
      round(100 * hard / calls, 3)  "Hard Parses(%%)",
      decode(round(100 * sess / calls, 3),0,decode(parm,0,-1,0),round(100 * sess / calls, 3)) 
          "Cursor Cache Hits(%%)"
from
      ( select value calls from v$sysstat where name = 'parse count (total)' ),
      ( select value hard from v$sysstat where name = 'parse count (hard)' ),
      ( select value sess from v$sysstat where name = 'session cursor cache hits' ),
      ( select value parm from v$parameter where name = 'session_cached_cursors')
/

/*
doc
Wait Event

Block Waits

    Purpose - ºí·Ï Ŭ·¡½ºº°·Î Wait ¹ß»ý³»¿ªÀ» È®ÀÎÇÑ´Ù.

    Description - ºí·Ï Ŭ·¡½ºº°·Î ¹ß»ýÇÑ ÃÑ WaitȽ¼ö¿Í ÃÑ Wait½Ã°£À» Á¡°ËÇÑ´Ù. Timed_statistics=True·Î ¼³Á¤µÇ¾î
              ÀÖ´Â °æ¿ì¿¡¸¸ ÀÌ °ªÀÌ ¾÷µ¥ÀÌÆ®µÈ´Ù. 
    Guide - Wait°¡ ½ÉÇÏ°Ô ¹ß»ýÇÑ ºí·Ï Ŭ·¡½º°¡ Á¸ÀçÇÒ °æ¿ì ÇØ´ç Ŭ·¡½ºÀÇ Æ¯¼º¿¡ µû¶ó ¿øÀÎÀ» ºÐ¼®ÇÏ¿© Á¶Ä¡ÇÏ¿©ÁØ´Ù.
          ¿¹¸¦ µé¾î, 'data block' Ŭ·¡½º¿¡ ´ëÇÑ ¼öÄ¡°¡ ³ô´Ù¸é µ¿½Ã Insert°¡ ¸¹Àº ¼¼±×¸ÕÆ®¸¦ ã¾Æ freelists¸¦
          Áõ°¡½ÃÄÑÁÖ´Â °ÍÀ» °í·ÁÇغ¼ ¼ö ÀÖÀ¸¸ç, 'segment header'³ª 'free list' Ç׸ñÀÌ ³ô´Ù¸é °æÇÕÀÌ ÀæÀº
          ¼¼±×¸ÕÆ®¸¦ ã¾Æ freelist groups¸¦ Áõ°¡½ÃÄÑÁÖ´Â °ÍÀ» °í·ÁÇÒ ¼ö ÀÖ´Ù. ¶ÇÇÑ 'undo header'³ª
          'undo block' Ç׸ñ¿¡ Wait°¡ ¸¹´Ù¸é ·Ñ¹é ¼¼±×¸ÕÆ®¿¡ ´ëÇÑ °æÇÕÀÌ Á¸ÀçÇÔÀ» ÀǹÌÇϹǷΠ·Ñ¹é ¼¼±×¸ÕÆ®ÀÇ
          °¹¼ö¸¦ Áõ°¡½ÃÄÑÁÖ´Â °ÍÀ» °í·ÁÇÒ ¼ö ÀÖ´Ù.
          ÀϹÝÀûÀ¸·Î wait°¡ ºó¹øÇÏ°Ô ¹ß»ýÇϴ Ŭ·¡½º´Â 'data block'Àε¥, ÀÌ °æ¿ì wait Ƚ¼ö°¡ Àüü request Ƚ¼ö
          (db block gets + consistent gets)ÀÇ 1%¸¦ ³ÑÁö ¾ÊÀ¸¸é Á¤»óÀ̶ó°í ÆÇ´ÜÇÒ ¼ö ÀÖ´Ù.
#
*/


select class, count, time
from
v$waitstat
/

/*
doc
System Wait Event

    Purpose - µ¥ÀÌŸº£À̽º ÀüüÀÇ Wait EventÀÇ Á¤º¸¸¦ È®ÀÎÇÑ´Ù.

    Description - µ¥ÀÌÅͺ£À̽º Àüü¿¡ ´ëÇØ ¹ß»ýÇÑ Event³»¿ªÀ» È®ÀÎÇÑ´Ù. ÀÌ °ªÀº v$system_event¸¦ Á¶È¸ÇÑ
          °ÍÀ̸ç ÀνºÅϽº ½ÃÀÛ ÈÄ ´©ÀûµÈ °ªÀÌ´Ù.ÀϺΠÇ÷§Æû¿¡¼­´Â timed_statistics ÆĶó¹ÌÅÍ°¡ FALSE·Î
          ¼³Á¤µÇ¾îÀÖÀ¸¸é time°ü·Ã Ç׸ñÀÌ 0·Î Ç¥½ÃµÈ´Ù. 
     
    Guide - °¢ Wait EventÀÇ Á¾·ù¿¡ µû¶ó¼­ WaitingÀÌ ¸¹ÀÌ ¹ß»ýÇÏ´Â Event ´ëÇÑ ÀûÀýÇÑ ÇØ°áÁ¶Ä¡¸¦ ÃëÇØ¾ß ÇÑ´Ù.
          ÀÌ·¯ÇÑ WaitingÀº ½ÇÁ¦ ¼öÇàµÇ´Â ÀÛ¾÷ÀÇ ¼º´ÉÀ» ÀúÇÏ ½ÃÅ°¹Ç·Î °¡Àå ¸¹ÀÌ ¹ß»ýÇÏ´Â Wait Event¸¦
          ÁßÁ¡ÀûÀ¸·Î ÇØ¼Ò ½ÃŲ´Ù. ÀÌ Á¤º¸´Â OrangeÀÇ Database Information Åø¿¡¼­µµ È®ÀÎ °¡´ÉÇÏ´Ù.

#
*/

col event format a35
select event, total_waits "Total Waits",
    time_waited "Time Waited(cs)",
    round(average_wait,5) "Avg Wait Time(cs)",
    total_timeouts "Total Timeouts"
from v$system_event
where event not like '%SQL*Net%'
      and event not like '%pipe get%'
      and event not like '%rdbms ipc%'
      and event not like '%smon timer%'
      and event not like '%pmon timer%'
      and time_waited > 0
order by time_waited desc
/

doc
Session Wait Event

    Purpose - ÇöÀç Á¢¼ÓÁßÀÎ SessionµéÀÇ Wait EventÁ¤º¸¸¦ È®ÀÎÇÑ´Ù.

    Description - ÇöÀç Á¢¼ÓµÈ ¸ðµç SessionµéÀÇ Wait EventÁ¤º¸À̸ç, ¼¼¼ÇÀÌ Á¢¼ÓµÈÀÌÈÄ ´©ÀûµÈ °ªÀÌ´Ù.
              v$session_event¸¦ Á¶È¸ÇÑ´Ù.
    Guide Wait EventÀÇ Á¾·ù¿¡ µû¶ó¼­ WaitingÀÌ ¸¹ÀÌ ¹ß»ýÇÏ´Â Event ´ëÇÑ ÀûÀýÇÑ ÇØ°áÁ¶Ä¡¸¦ ÃëÇØ¾ß ÇÑ´Ù.
              ÀÌ·¯ÇÑ WaitingÀº ½ÇÁ¦ ¼öÇàµÇ´Â ÀÛ¾÷ÀÇ ¼º´ÉÀ» ÀúÇÏ ½ÃÅ°¹Ç·Î °¡Àå ¸¹ÀÌ ¹ß»ýÇÏ´Â Wait Event¸¦
              ÁßÁ¡ÀûÀ¸·Î ÇØ¼Ò ½ÃŲ´Ù.
#
col event format a35
select sid, event,
        total_waits "Total Waits",
        time_waited "Time Waited (cs)",
        round(average_wait,5) "Avg Wait Time (cs)",
        total_timeouts "Total Timeouts"
from v$session_event
where event not like '%SQL*Net%'
    and event not like '%pipe get%'
    and event not like '%rdbms ipc%'
    and event not like '%smon timer%'
    and event not like '%pmon timer%'
and time_waited > 0
order by time_waited desc
/

doc
~~~~ I/O ~~~~

File I/O

    Purpose - µ¥ÀÌÅÍ ÆÄÀÏÀÇ I/O Á¤µµ ¹× ½Ã°£À» È®ÀÎÇÑ´Ù.

    Description - Read(%), Write(%), Total IO(%)´Â µ¥ÀÌÅͺ£À̽º³»ÀÇ ¸ðµç ÆÄÀÏ¿¡ ´ëÇÑ Read, Write,
            Read+Write °¡¿îµ¥ ÇØ´ç ÆÄÀÏÀÌ Â÷ÁöÇÏ´Â ºñÀ²ÀÇ ÀǹÌÇÑ´Ù.
    Guide - Æò±Õ I/O ½Ã°£ÀÌ ±ä µ¥ÀÌÅÍ ÆÄÀÏ¿¡ ´ëÇؼ­´Â ÇØ´ç µ¥ÀÌÅÍ ÆÄÀÏÀÌ À§Ä¡ÇÑ DiskÀÇ ¼º´ÉÀ» °í·ÁÇØ
          ºÁ¾ß Çϸç, ¸¹Àº µ¥ÀÌÅÍ ÆÄÀÏÀÌ °°Àº À§Ä¡¿¡ ÀÖÀ¸¹Ç·Î Çؼ­ ¹ß»ýÇÏ´Â I/O º´¸ñÇö»óÀÌ ¹ß»ýÇÏ´ÂÁö¸¦
          È®ÀÎÇØ¾ß ÇÑ´Ù. ¶ÇÇÑ, I/O°¡ ¸¹ÀÌ ¹ß»ýÇÏ´Â µ¥ÀÌÅÍ ÆÄÀÏÀº ÇϳªÀÇ Device¿¡ ¸ô¸®Áö ¾Êµµ·Ï ºÐ»ê½ÃŲ´Ù.
#

col "Name" format a50
SELECT name "Name",
      phyrds "Phy Rds",
      phywrts "Phy Wrts",
      phyrds+phywrts "Total IO",
      trunc(phyrds/read_sum*100,2) "Read(%%)",
      trunc(phywrts/write_sum*100,2) "Write(%%)",
      trunc( (phyrds+phywrts) / (read_sum+write_sum) * 100 , 2) "Total IO(%%)",
      avgiotim "Avg IO Time"
FROM v$filestat a, v$datafile b,
        (select sum(phyrds) read_sum, sum(phywrts) write_sum
        from v$filestat ) c
WHERE a.file# = b.file#
order by phyrds+phywrts desc
/


doc
Memory Sort Ratio

    Purpose - Á¤·ÄÀÛ¾÷ÀÌ ¸Þ¸ð¸®¿¡¼­ ¼öÇàµÈ ºñÀ²À» È®ÀÎÇÑ´Ù.

    Description - Order by, Group by ±¸¹®Ã³¸®, Join¼öÇà, Index »ý¼º µîÀ» ó¸®Çϱâ À§Çؼ­´Â Á¤·ÄÀÛ¾÷À»
          ÇÊ¿ä·ÎÇÑ´Ù. ÀÌ·¯ÇÑ Á¤·ÄÀÛ¾÷Àº °¡´ÉÇÑ ¸Þ¸ð¸®(Sort Area)³»¿¡¼­ ¼öÇàµÇ´Â °ÍÀÌ ¹Ù¶÷Á÷Çϳª,
          󸮷®ÀÌ ¸¹¾Æ ¸Þ¸ð¸®¿¡¼­ ¼öÇàµÉ ¼ö ¾ø´Â °æ¿ì ¿À¶óŬÀº Temporary Segment¸¦ »ç¿ëÇÑ´Ù.
       
    Criteria - 99.0 % Minimum

    Guide - ¸Þ¸ð¸®¿¡¼­ Á¤·ÄÀÛ¾÷À» ¼öÇàÇÑ ºñÀ²ÀÌ 99%°¡ ³ÑÁö ¾ÊÀ» °æ¿ì¿¡´Â init.oraÀÇ sort_area_size¸¦ Áõ°¡ÇÑ´Ù.
            º¸ÅëÀÇ °æ¿ì OLTP ½Ã½ºÅÛ¿¡¼­´Â 500K ~ 10M ±îÁö ÁöÁ¤ÇÏ°í DW ½Ã½ºÅÛ¿¡¼­´Â 1M ~ 50M ±îÁö ÁöÁ¤ÇÑ´Ù.
            ¶ÇÇÑ sort_area_retained_size´Â sort_area_sizeÀÇ 1/2À̳ª 1/4·Î ÁöÁ¤ÇÑ´Ù.
    ÁÖÀÇ : ÀÌ ¸Þ¸ð¸® °ø°£Àº SGA³»¿¡ Á¸ÀçÇÏ´Â °ÍÀÌ ¾Æ´Ï¶ó °¢°¢ÀÇ ÇÁ·Î¼¼½ºº°·Î ÇÒ´çµÇ±â ¶§¹®¿¡ O/SÀÇ Àüü
              ¸Þ¸ð¸®ÀÇ ¿©À¯°¡ ÀÖÀ» °æ¿ì¿¡ Áõ°¡½ÃŲ´Ù.
#

select a.value "Sort(memory)",
      b.value "Sort(disk)",
      round(a.value/(a.value+b.value) * 100 ,2) "Memory Sort Ratio"
from v$sysstat a, v$sysstat b
      where a.name = 'sorts (memory)'
      and b.name = 'sorts (disk)'
/

                               
doc

Sort Segment Usage

    Purpose - Sort SegmentÀÇ »ç¿ë·®À» º¸¿© ÁØ´Ù.

    Description - ¾Õ¼­ ¾ð±ÞÇÑ ¹Ù¿Í°°ÀÌ, Á¤·Ä´ë»óÀÌ sort_area_sizeº¸´Ù Ŭ °æ¿ì¿¡ ¿À¶óŬÀº µð½ºÅ©»óÀÇ Temporary
            ¿µ¿ªÀ» »ç¿ëÇÏ°Ô µÇ´Âµ¥, À̶§ »ý¼ºÇÏ¿© »ç¿ëÇÏ´Â °ÍÀÌ Sort SegmentÀÌ´Ù. V$sort_segment¸¦ Á¶È¸ÇÑ´Ù.
    Guide - Sort SegmentÀÇ ÃÖ´ë »ç¿ë·®, ÇöÀç »ç¿ë·®µîÀ» È®ÀÎÇÏ¿© sort segment¸¦ ÀúÀåÇÏ´Â TablespaceÀÇ °ø°£
            ¿¹ÃøÀÌ °¡´ÉÇÏ´Ù.
#                               

SELECT tablespace_name "Tablespace Name",
      extent_size "Extent Size",
      current_users "Current Users",
      total_extents "Total Exts",
      used_extents "Used Exts",
      free_extents "Free Exts",
      max_used_size "Max Used Exts"
FROM v$sort_segment
/

doc
Redo Log Switch Count(Hourly)

    Purpose - ½Ã°£º° Redo Log SwitchÀÇ È½¼ö¸¦ È®ÀÎÇÑ´Ù

    Description - ÃÖ±Ù 3ÀÏ°£¿¡ ´ëÇÏ¿© ¸Å½Ã°£º° ¹ß»ýÇÑ Log SwitchÀÇ ¹ß»ýȽ¼ö¸¦ º¸¿©ÁØ´Ù.

    Guide - redo logÀÇ Switch Ƚ¼ö·Î µ¥ÀÌŸº£À̽ºÀÇ Transaction¾çÀ» ¿¹ÃøÇÒ ¼ö ÀÖÀ¸¸ç ÇÏ·ç Áß¿¡ °¡Àå
            TransactionÀÌ ¸¹Àº ½Ã°£À» ÆľÇÇÒ¼ö ÀÖ´Ù. ÀÌ·¸µí ¸¹Àº TransactionÀÌ ¹ß»ýÇÏ´Â ½Ã°£¿¡´Â ´ë·®ÀÇ
            Batch JobÀ» °¡´ÉÇÑÇÑ ´Ù¸¥½Ã°£¿¡ ¼öÇàÅä·Ï ÇÏ´Â °ÍÀÌ ¹Ù¶÷Á÷ÇÏ´Ù.
#

select thread#, to_char(first_time, 'yyyy/mm/dd hh24') "Time", count(*) "Count"
from v$loghist
where first_time  > sysdate -3
group by thread#, to_char(first_time, 'yyyy/mm/dd hh24')
/

doc

Redo Log Switch Count(Daily)

    Purpose - ÀÏÀÚº° Redo Log SwitchÀÇ È½¼ö¸¦ È®ÀÎÇÑ´Ù.
   
    Description - ÃÖ±Ù 30ÀÏ°£¿¡ ´ëÇÏ¿© ¸ÅÀÏ ¹ß»ýÇÑ Log SwtichÀÇ ¹ß»ýȽ¼ö¸¦ º¸¿©ÁØ´Ù.
   
    Guide - redo logÀÇ Switch Ƚ¼ö·Î µ¥ÀÌŸº£À̽ºÀÇ Transaction¾çÀ» ¿¹ÃøÇÒ ¼ö ÀÖÀ¸¸ç ÇÑ´ÞÁß¿¡ °¡Àå
        TransactionÀÌ ¸¹Àº ³¯Â¥À» ÆľÇÇÒ¼ö ÀÖ´Ù.
#

select thread#, to_char(first_time, 'yyyy/mm/dd') "Time", count(*) "Count"
from v$loghist
where first_time  > sysdate -30
group by thread#, to_char(first_time, 'yyyy/mm/dd')
/


doc
Redo Log Switch Time Interval

    Purpose - Redo Log SwitchÀÇ Time IntervalÀ» È®ÀÎÇÑ´Ù. 

    Description - ÃÖ±Ù 3ÀÏ°£¿¡ ´ëÇÏ¿© Log Switch°¡ ¹ß»ýÇÑ °£°ÝÀ» ½Ã°£´ç Æò±Õ¼öÄ¡·Î º¸¿©ÁØ´Ù.

    Criteria - 10.0 min Minimum

    Guide - Redo Log SwitchÀÇ Time IntervalÀÌ 10ºÐÀÌÇÏ·Î °è¼ÓµÈ´Ù¸é, redo log fileÀÇ size¸¦ Áõ°¡½ÃÄѼ­
            redo log switch°¡ ³Ê¹« ÀÚÁÖ ¹ß»ýÇÏÁö ¾Êµµ·Ï ÇÏ¿© checkpoint¿¡ ÀÇÇÑ I/O¸¦ ¿¹¹æÇÒ ¼ö ÀÖ´Ù,
            ¶ÇÇÑ »ý·«ÇÒ ¼ö ÀÖ´Â µ¥ÀÌÅͺ£À̽º³»ÀÇ TrasactionÀ» ¾ø¾Ö´Â ¹æ½ÄÀ¸·Î ÀÛ¾÷À» ÇÏ¿© ¼º´ÉÀÇ
            °³¼±È¿°ú¸¦ º¼¼ö ÀÖ´Ù
    ¿¹: CREATE TABLE AS SELECT ¡¦ NOLOGGING, CREATE INDEX ..... NOLOGGINGµî.
#


select /*+ use_hash(a b) */ a.thread#, to_char(a.first_time,'YYYY/MM/DD HH24') "Time",
        round(avg(trunc((a.first_time - b.first_time)*24*60,3)),2) "Interval(Min)"
from
      (select thread#, sequence#, first_time  from v$loghist where first_time  > sysdate -3) a,
      (select thread#, sequence#, first_time  from v$loghist where first_time  > sysdate -3) b
where a.thread# = b.thread#
        and a.sequence# = b.sequence# + 1
group by a.thread#, to_char(a.first_time,'YYYY/MM/DD HH24')
/

doc
~~~ Space ~~~

Objects With Too Many Extents

    Purpose - µ¥ÀÌŸº£À̽º ³»¿¡ Extent°¡ ¸¹ÀÌ ¹ß»ýÇÑ ObjectÀ» È®ÀÎÇÑ´Ù.

    Description - Extent°¡ 50°³ ÀÌ»ó ¹ß»ýÇÑ ¿ÀºêÁ§Æ® °¡¿îµ¥ Top-N°³¸¦ º¸¿©ÁØ´Ù. ExtentsÀÇ ¼ö°¡ ¸¹Àº °ÍÀÌ
            ¹Ýµå½Ã ½É°¢ÇÑ ¼º´ÉÀúÇÏ·Î ¿¬°áµÇÁö´Â ¾ÊÁö¸¸ ExtentÀÇ ÀæÀº ½Ç½Ã°£À¸·Î ÇÒ´çÀ¸·Î ÀÎÇØ ¼º´É»ó ÀÌ·ÓÁö
            ¸øÇÑ °ÍÀº ºÐ¸íÇÏ´Ù. ÁÖ±âÀûÀÎ Extent ¹ß»ýÇöȲÀÇ Á¡°Ë°ú ¿ÀºêÁ§Æ®º° ÀûÀýÇÑ ÀúÀå¿É¼Ç ¼³Á¤ÀÛ¾÷À»
            ¼öÇàÇÏ¿© ÁÖ´Â °ÍÀÌ ¹Ù¶÷Á÷ÇÏ´Ù. 
       
    Guide - Extent°¡ Áö³ªÄ¡°Ô ¸¹ÀÌ ¹ß»ýÇÑ ¿ÀºêÁ§Æ®¿¡ ´ëÇؼ­´Â Next ExtentsÀÇ Å©±â¸¦ µ¥ÀÌÅÍ Áõ°¡¼öÁØ¿¡ ¸Â°Ô
            Á¶Á¤ÇÏ¿© ÀÚÁÖ Extent°¡ ¹ß»ýÇÏÁö ¾Êµµ·Ï ÇÏ°í, ÇÊ¿äÇÑ °æ¿ì ReorgÀÛ¾÷À» ¼öÇàÇÑ´Ù.
#

col owner format a10
col "Segment" format a30
col "Tablespace" format a20

select owner,
      segment_name "Segment",
      segment_type "Type",
      tablespace_name "Tablespace",
      round(bytes/1024/1024,2) "Size(MB)",
      extents  "Extents",
      round(initial_extent/1024/1024,2) "Initial(MB)",
      round(next_extent/1024/1024,2) "Next(MB)"
from dba_segments
where owner != 'SYS'
and extents > 50
order by extents desc
/

doc
Tablespace Usage and Fragmentation

    Purpose - Å×ÀÌºí ½ºÆäÀ̽ºÀÇ »ç¿ëÇöȲ°ú FragmentationÀ» Á¡°ËÇÑ´Ù

    Description - Å×ÀÌºí ½ºÆäÀ̽ºÀÇ ÃÑ ÇÒ´ç·®°ú »ç¿ë·®À» Á¡°ËÇÏ°í, Free SpaceÀÇ ÃÑ Å©±â¿Í Max Free ExtentÀÇ Å©±â,
              Free Extent °¹¼ö µî Fragmentation ³»¿ªÀ» È®ÀÎÇÑ´Ù. Å×ÀÌºí ½ºÆäÀ̽º°¡ FragmentationÀÌ ¸¹ÀÌ ¹ß»ýÇßÀ»
              °æ¿ì¿¡´Â »õ·Î¿î Extent¸¦ »ý¼ºÇÒ ¶§ ³²Àº °ø°£ÀÌ ÀÖÀ½¿¡µµ ¿¬¼ÓÀûÀÎ Å©±âÀÇ Free °ø°£ÀÌ ¾ø¾î¼­ Error°¡
              ¹ß»ýÇÒ ¼ö ÀÖ´Ù. 
       
    Guide - ¸¸¾à Free spaceµéÀÌ ¼­·Î ¿¬¼ÓµÇ¾î ÀÖÁö ¾Ê¾Æ º´ÇÕÀÌ ºÒ°¡´ÉÇÑ »óÅÂÀÏ °æ¿ì¿¡´Â Object¸¦ ExportÇÑ ÈÄ
              CoalesceÇÏ°í ´Ù½Ã importÇÏ¿© FragmentationÀ» ÇØ¼Ò ÇÒ ¼ö ÀÖ´Ù. ¹Ù¶÷Á÷ÇÑ °ÍÀº FragmentationÀ» »çÀü¿¡
              ¿¹¹æÇÏ´Â °ÍÀ̸ç, À̸¦ ¿¹¹æÇϱâ À§Çؼ­ Å×ÀÌºí ½ºÆäÀ̽º ´ÜÀ§·Î »ý¼ºµÇ´Â ¿ÀºêÁ§Æ®ÀÇ extentÀÇ Å©±â¸¦
              ´Ü°èº°·Î 1M, 10M, 50M, 100MµîÀ¸·Î Á¤ÇÏ¿© »ý¼ºÇÏ´Â ¹æ¹ýµµ ÀÖ´Ù. Å×ÀÌºí½ºÆäÀ̽º¿Í ¼¼±×¸ÕÆ®ÀÇ ¹°¸®Àû
              ÀúÀå»óÅ´ ¿À·»ÁöÀÇ Space Manager¸¦ »ç¿ëÇÏ¿© ½±°Ô È®ÀÎÇÒ ¼ö ÀÖ´Ù.
#

select df.tablespace_name "Tablespace",
        round(df.TBS_byte /1048576,2) "Total(MB)",
        round((df.TBS_byte - fs.Free_byte)/1048576,2) "Used(MB)",
        round(fs.Free_byte /1048576,2) "Free(MB)",
        round((fs.Free_byte/df.TBS_byte) *100,0) "Free(%%)",
        fs.pieces "Pieces",
        round(fs.Max_free /1048576,2) "MaxFree(MB)"
from  ( select tablespace_name, sum(bytes) TBS_byte
        from dba_data_files group by tablespace_name ) df,
        ( select tablespace_name, max(bytes) Max_free, sum(bytes) Free_byte, count(*) pieces
        from dba_free_space group by tablespace_name ) fs,
        ( select tablespace_name, initial_extent, next_extent
        from dba_tablespaces ) db
where df.tablespace_name = db.tablespace_name
and  df.tablespace_name = fs.tablespace_name(+)
order by 5
/

doc
Objects with Possible Extent Problem

    Purpose - next extents°¡ ¹ß»ýÇÒ °æ¿ì¿¡ °ø°£ÀÇ ºÎÁ·À¸·Î Error°¡ ¹ß»ýÇÒ ¿©Áö°¡ ÀÖ´Â Object¸¦ È®ÀÎÇÑ´Ù

    Description - next extents°¡ ¹ß»ýÇÒ °æ¿ì¿¡ °ø°£ÀÇ ºÎÁ·À¸·Î Error°¡ ¹ß»ýÇÒ ¿©Áö°¡ ÀÖ´Â Object¸¦ È®ÀÎÇÑ´Ù.
            ³²¾ÆÀÖ´Â Free Extent °¡¿îµ¥ °¡Àå Å« Á¶°¢º¸´Ù Å« Next Extent°¡ ¼³Á¤µÇ¾îÀÖ´Â Å×À̺íÀÌ Á¸ÀçÇÒ °æ¿ì
            ´ÙÀ½ ExtentÇÒ´ç½Ã Error°¡ ³¯ ¼ö ÀÖÀ¸¹Ç·Î »çÀü¿¡ Á¶Ä¡¸¦ ÃëÇØÁÖ¾î¾ß ÇÑ´Ù.
       
    Guide - ÇâÈÄ »çÀÌÁîÀÇ Áõ°¡°¡ Å©Áö ¾ÊÀ» °ÍÀ¸·Î ¿¹»óµÇ´Â TableÀÏ °æ¿ì¿¡´Â Next Extent¸¦ ÀÛÀº »çÀÌÁî·Î
            º¯°æÇÏ°í, ¸¸¾à ÇØ´ç TableÀÌ Á¡Á¡ Ä¿Áú ¼ö ÀÖ´Â °æ¿ì¶ó¸é Å×ÀÌºí½ºÆäÀ̽º ÀÚüÀÇ Å©±â¸¦ Áõ°¡½ÃÄÑ
            ÁÖ¾î¾ß ÇÑ´Ù.

#

select u.name owner,
        o.name segment_name,
        so.object_type segment_type,
        f.name tablespace_name,
        round(f.avail/1024/1024, 1) "Max Free(MB)",
        round(s.extsize * f.blocksize/1024/1024, 1) "Next(MB)",
        round(s.blocks*f.blocksize/1024/1024, 1) "Total Size(MB)",
        s.extents "Exts"
from sys.obj$ o,
        sys.sys_objects so,
        sys.seg$ s,
        sys.user$ u,
        (
            select ts.ts#, ts.name, ts.blocksize,
                    max(f.length * ts.blocksize) avail
            from sys.ts$ ts,
              sys.fet$ f
            where ts.ts# = f.ts#
            and ts.bitmapped = 0
            group by ts.ts#, ts.name, ts.blocksize ) f
where s.file# = so.header_file
      and s.block# = so.header_block
      and f.ts# = so.ts_number
      and s.ts# = f.ts#
      and o.obj# = so.object_id
      and o.owner# = u.user#
      and s.type# = so.segment_type_id
      and o.type# = so.object_type_id
      and so.object_type in ('TABLE', 'INDEX', 'CLUSTER')
      and sign(f.avail-s.extsize * f.blocksize) = -1
/

doc
Rollback Segment Hit Ratio

    Purpose - Rollback SegmentÀÇ Hit Ratio¸¦ È®ÀÎÇÑ´Ù

    Description - Rollback SegmentÀÇ °¹¼öº¸´Ù µ¿½Ã TransactionÀÇ ¼ö°¡ ¸¹Àº °æ¿ì Rollback segmentÀÇ ÇÒ´ç½Ã
            WaitingÀÌ ¹ß»ýÇϹǷΠOnline Rollback SegmentÀÇ °³¼ö¸¦ ´Ã·ÁÁÖ¾î¾ß ÇÑ´Ù.
       
    Criteria - 99.0 % Minimum

    Guide  - Rollback SegmentÀÇ °³¼ö´Â ÀϹÝÀûÀ¸·Î ¾Æ·¡ÀÇ °ø½Ä¿¡ µû¶ó ¼³Á¤Ç쵂 ÃÖ´ë 50°³¸¦ ³ÑÁö ¾Ê´Â °ÍÀÌ ÁÁ´Ù.
  N < 16 --> 4 rbs
  16 <= N <= 32 --> 8 rbs
  32 < N --> N/4 rbs
  ( N: µ¿½Ã Æ®·£Àè¼ÇÀÇ ¼ö )
            ¶ÇÇÑ, ·Ñ¹é ¼¼±×¸ÕÆ®´Â Online Æ®·£Àè¼Ç ¿ë°ú ¹èÄ¡ ÀÛ¾÷¿ëÀ¸·Î ±¸ºÐÇؼ­ »ý¼ºÇÏ´Â °ÍÀÌ ÁÁ´Ù. Online
            Æ®·£Àè¼Ç ¿ëÀ¸·Î´Â ´ëºÎºÐ initial 1M, next 1M À̸é ÃæºÐÇÏ¸ç ¹èÄ¡ ÀÛ¾÷¿ëÀº ÀÛ¾÷ÀÇ ¾ç¿¡ µû¶ó Å©±â¸¦
            Å©°Ô »ý¼ºÇÑ´Ù. ¹°·Ð ¹èÄ¡ÀÛ¾÷À» ¼öÇà ÇÒ ¶§´Â ¹èÄ¡ ÀÛ¾÷¿ë ·Ñ¹é¼¼±×¸ÕÆ®¸¦ »ç¿ëÅä·Ï Æ®·£Àè¼ÇÀÇ ½ÃÀÛ
            ºÎºÐ¿¡¼­ 'set transaction use rollback segment big_rbs01;'¸¦ ¸ÕÀú ¼öÇàÇÏ°í ¹èÄ¡ÀÛ¾÷À» ¼öÇàÇÑ´Ù


#

select name "Rollback Segment",
    rssize "Rsize", writes "Writes", xacts "Xacts", status "Status",
    waits "Waits", gets "Gets",
    decode(gets,0,-1, trunc((1-(waits/gets))*100, 5)) "Hit ratio"
from v$rollstat, v$rollname
where v$rollstat.usn = v$rollname.usn
order by waits/gets desc
/

doc

User Objects in SYSTEM Tablespace

    Purpose - System Tablespace³»ÀÇ ÀÏ¹Ý UserÀÇ Object¸¦ È®ÀÎÇÑ´Ù

    Description - System Tablespace´Â µ¥ÀÌŸº£À̽º ¿î¿µÀ» À§ÇØ ¿À¶óŬ¿¡ ÀÇÇØ ºó¹øÇÏ°Ô »ç¿ëµÇ´Â ¿µ¿ªÀ̹ǷΠÀϹÝ
            À¯ÀúÀÇ Object´Â ´Ù¸¥ Tablespace·Î ¿Å°Ü¾ß ÇÑ´Ù.
       
    Guide - SYSTEM Å×ÀÌºí½ºÆäÀ̽º¿¡ ÀúÀåµÈ ¿ÀºêÁ§Æ®µéÀº Export¸¦ ÇÑÈÄ »õ·Î¿î Tablespace¿¡ CreateÇÏ°í µ¥ÀÌÅ͸¦
            ImportÇϰųª 'Alter table move ¡¦' µîÀÇ ¸í·É¾î¸¦ ÀÌ¿ëÇÏ¿© ¿Å±ä´Ù.
#

select owner "Owner", segment_name "Segment Name", segment_type "Segment Type"
from dba_segments
where tablespace_name = 'SYSTEM'
and owner not in ('SYSTEM', 'SYS', 'OUTLN', 'DBSNMP', 'MDSYS', 'ORDSYS','OLAPDBA', 'ORDPLUGINS',
'OLAPSVR', 'OSE$HTTP$ADMIN', 'AURORA$ORB$UNAUTHENTICATED', 'AURORA$JIS$UTILITY$')
/


doc

~~~ Access Type ~~~

SQLs by cached time

    Purpose - ij½¬±â°£¿¡ µû¸¥ SQL °¹¼ö¿Í Æò±Õ ½ÇÇà Ƚ¼ö¸¦ ÆľÇÇÑ´Ù.

    Description - ¶óÀ̺귯¸® ij½¬¿¡ ij½¬µÇ¾îÁø ±â°£¿¡ µû¸¥ ±¸°£º° SQL °¹¼ö¿Í Æò±Õ ½ÇÇàȽ¼ö¸¦ Á¡°ËÇÏ¿© Çö ½Ã½ºÅÛÀÇ
          SQLÀÇ °øÀ¯µµ¿Í ¼öÇàƯ¼ºÀ» ÆľÇÇÑ´Ù. SYS À¯Àú·Î ¼öÇàµÈ SQLÀº Á¦¿ÜÇÏ¸ç µ¿ÀÏ SQL¿¡ ´ëÇÑ ¹öÀüÀÌ ¿©·¯°³ÀÏ
          °æ¿ì¿¡ Parent Cursor¿¡ ´ëÇؼ­¸¸ CountÇÑ´Ù.

#

select substr(cache_time,3) "Cached time", count(*) "SQL Count", round(avg(exec)) "Avg Exec Count"
from
    ( select decode(sign(1-(sysdate-to_date(first_load_time,'yyyy-mm-dd/hh24:mi:ss'
))*24*60),1,'1        00 ~ 01 (min)',
    decode(sign(5-(sysdate-to_date(first_load_time,'yyyy-mm-dd/hh24:mi:ss'
))*24*60),1,'2  01 ~ 05 (min)',
    decode(sign(10-(sysdate-to_date(first_load_time,'yyyy-mm-dd/hh24:mi:ss
'))*24*60),1,'3  05 ~ 10 (min)',
    decode(sign(30-(sysdate-to_date(first_load_time,'yyyy-mm-dd/hh24:mi:ss
'))*24*60),1,'4        10 ~ 30 (min)',
    decode(sign(60-(sysdate-to_date(first_load_time,'yyyy-mm-dd/hh24:mi:ss
'))*24*60),1,'5  30 ~ 60 (min)',
    decode(sign(60*2-(sysdate-to_date(first_load_time,'yyyy-mm-dd/hh24:mi:
ss'))*24*60),1,'6  01 ~ 02 (hour)',
    decode(sign(60*12-(sysdate-to_date(first_load_time,'yyyy-mm-dd/hh24:mi
:ss'))*24*60),1,'7  02 ~ 12 (hour)',
    decode(sign(60*24-(sysdate-to_date(first_load_time,'yyyy-mm-dd/hh24:mi
:ss'))*24*60),1,'8  12 ~ 24 (hour)','9        24 ~    (hour)')))))))) cache_time
    , executions exec
from v$sql
where parsing_user_id > 0 and child_number = 0
)
group by cache_time
/

doc
SQLs by Execution Count

    Purpose - ½ÇÇàȽ¼ö¿¡ µû¸¥ SQL °¹¼ö¸¦ ÆľÇÇÑ´Ù

    Description - ¶óÀ̺귯¸® ij½¬¿¡ ij½¬µÇ¾îÁø SQL¿¡ ´ëÇÏ¿© ½ÇÇàȽ¼öº° ºÐÆ÷¸¦ Á¡°ËÇÏ¿© °øÀ¯µµ¿Í °øÀ¯¸Þ¸ð¸® Á¡À¯»óÅ µîÀÇ Æ¯¼ºÀ»
              ÆľÇÇÑ´Ù. SYS À¯Àú·Î ¼öÇàµÈ SQLÀº Á¦¿ÜÇÏ¸ç µ¿ÀÏ SQL¿¡ ´ëÇÑ ¹öÀüÀÌ ¿©·¯°³ÀÏ °æ¿ì¿¡ Parent Cursor¿¡ ´ëÇؼ­¸¸ CountÇÑ´Ù.

#

select decode(executions,0,'  0',
decode(sign(2-executions),1,'  01',
decode(sign(3-executions),1,'  02',
decode(sign(6-executions),1,'03-05',
decode(sign(11-executions),1,'06-10',
decode(sign(21-executions),1,'11-20',
decode(sign(41-executions),1,'21-40','41+'))))))) "Exec Count",
count(*) "SQL Count", round(sum(sharable_mem)/1024,2) "Used Mem(KB)"
FROM V$SQL
WHERE parsing_user_id > 0 and child_number = 0
GROUP BY decode(executions,0,'  0',
decode(sign(2-executions),1,'  01',
decode(sign(3-executions),1,'  02',
decode(sign(6-executions),1,'03-05',
decode(sign(11-executions),1,'06-10',
decode(sign(21-executions),1,'11-20',
decode(sign(41-executions),1,'21-40','41+')))))))
/

doc
Literal SQL

    Purpose - SGA³»¿¡ »ç¿ëµÈ Literal SQLÀ» È®ÀÎÇÑ´Ù

    Description OLTP ½Ã½ºÅÛÀÇ °æ¿ì Á¶È¸ Á¶°ÇÀÇ ÀϺθ¸ º¯Çϸ鼭 ºó¹øÈ÷ ¼öÇàµÇ´Â SQLÀÌ ¸¹Àºµ¥ ÀÌ·¯ÇÑ SQLµéÀÌ Literal SQL·Î
              ÀÛ¼ºµÇ¸é ¶óÀ̺귯¸® ij½¬ ³»¿¡¼­ Ç×»ó ´Ù¸¥ SQL·Î ÀÎ½ÄµÇ¾î °øÀ¯µÉ ¼ö ¾øÀ¸¹Ç·Î ¼öÇà ½Ã¸¶´Ù ¸Å¹ø ÆĽÌÀ» ¼öÇàÇؾß
              ÇÑ´Ù. ÀÌ¿Í °°Àº Literal SQLÀÌ ½Ã½ºÅÛ ¼º´ÉÀ» ÀúÇϽÃÅ°´Â ÁÖ¹üÀÌ µÇ´Â °æ¿ì°¡ ¸¹À¸¹Ç·Î ¼ö½Ã·Î Á¡°ËÇÏ¿© ÀûÀýÇÑ
              Æ©´×ÀÛ¾÷À» ¼öÇàÇØ ÁÖ´Â °ÍÀÌ ÁÁ´Ù. 
         
    Guide - Literal SQLÀ» ÃßÃâÇÏ¿© °¡´ÉÇÑ ¹ÙÀÎµå º¯¼ö¸¦ »ç¿ëÇϵµ·Ï ¼öÁ¤ÇØ ÁÖ¾î¾ß ÇÑ´Ù.
   
#
col "SQL" format a40
select substr(sql_text, 1, 40) "SQL",
    count(*) "Count",
    sum(executions) "TotExecs",
    sum(sharable_mem) "Mem",
    to_char(to_date(min(first_load_time), 'yyyy-mm-dd/hh24:mi:ss'), 'yyyy/mm/dd hh24:mi:ss') "Start Time",
    to_char(to_date(max(first_load_time), 'yyyy-mm-dd/hh24:mi:ss'), 'yyyy/mm/dd hh24:mi:ss') "End TIme",
    max(hash_value) "Hashval"
from v$sql
where executions < 5
    group by substr(sql_text, 1, 40)
    having count(*) > 30
    order by 2 desc
/

doc
¸¸¾à À§ÀÇ ÀÚ¼¼ÇÑ Á¤º¸°¡ ÇÊ¿äÇÏ¸é ¼öÇàÇÒ °Í(40->100º¯°æ)
       
        col module format a20
        col sql_text format a60
       
        select main.module,  main.sql_text
        from
        v$sql main,  (    select substr(sql_text, 1, 40) as s_text    from v$sql 
            where executions < 5    group by substr(sql_text, 1, 40)    having
          count(*) > 30) inview where substr(main.sql_text, 1, 40) = inview.s_text
          order by module, sql_text desc
        /
#

doc
Chained Row Ratio   

    Purpose - Chained Row¸¦ AccessÇÑ ºñÀ²À» È®ÀÎÇÑ´Ù.

    Description - Table Full Scan ¶Ç´Â Index Scan¿¡ ÀÇÇØ ¾×¼¼½ºµÈ ¸ðµç ·Î¿ì°¡¿îµ¥ Row Chaining¿¡ ÀÇÇؼ­ Ãß°¡·Î
              ¾×¼¼½º°¡ ¹ß»ýÇÑ ºñÀ²À» È®ÀÎÇÑ´Ù.
         
    Criteria - 1.0 % Maximum

    Guide - Chained Row¸¦ AccessÇÑ ºñÀ²ÀÌ 1% ÀÌ»óÀÇ °ªÀÌ ³ª¿Ã °æ¿ì¿¡´Â ÀÚÁÖ »ç¿ëµÇ´Â Object¿¡ ChainingÀÌ ¸¹ÀÌ
            ¹ß»ýÇÏ¿´À½À» ÀǹÌÇϹǷΠÀ̸¦ ReorgÇÏ¿©¼­ ChainingÀ» ¾ø¾ÖÁÖ´Â °ÍÀÌ ÁÁ´Ù.

#
SELECT sum(decode(name,'table fetch continued row',value,0)) "Chained row Access",
  sum(decode(name,'table fetch by rowid',value,0)) "Index Access",
  sum(decode(name,'table scan rows gotten',value,0)) "Table Scan Access",
  round(sum(decode(name,'table fetch continued row',value,0)) /
  (sum(decode(name,'table fetch by rowid',value,0)) + sum(decode(name,'table scan rows gotten',value,0))) * 100,5) "Ratio"
FROM v$sysstat
/


doc

Session Index Scan Ratio

Purpose - sessionº°·Î Full table scan°ú Index ScanÀÇ ºñÀ²À» È®ÀÎÇÑ´Ù.

Description - sessionº°·Î Full table scan°ú Index ScanÀÇ ºñÀ²À» È®ÀÎÇÑ´Ù. Ç×»ó À妽º ½ºÄµÀÌ À¯¸®ÇÑ
        °ÍÀº ¾Æ´ÏÁö¸¸ ÀϹÝÀûÀ¸·Î ³ôÀº À妽º ½ºÄµºñÀ²À» À¯ÁöÇÏ´Â °ÍÀÌ ¹Ù¶÷Á÷ÇÏ´Ù. Full ScanÀÌ Áö³ªÄ¡°Ô ¸¹Àº
        ¼¼¼ÇÀº ÀÏ´Ü Á¡°ËÇÏ¿© ºñÈ¿À²¼ºÀ»  °ËÅäÇغ¼ ÇÊ¿ä°¡ ÀÖ´Ù. 
       
Criteria - 90.0 % Minimum

Guide  - ÀϹÝÀûÀ¸·Î À妽º ½ºÄµ ºñÀ²ÀÌ 90%ÀÌ»óÀ» À¯ÁöÇÏ´Â °ÍÀÌ ¹Ù¶÷Á÷ Çϸç, Á¢¼ÓµÇ¾î ÀÖ´Â ¼¼¼ÇÁß¿¡ ±ÇÀå°ª ÀÌÇÏÀÎ
        ¼¼¼Ç¿¡ ´ëÇؼ­´Â ÇØ´ç SessionÀ» »ç¿ëÇÏ´Â Application¿¡ ´ëÇÑ ºÐ¼®°ú Æ©´×À» ÅëÇÏ¿© ºñÈ¿À²ÀûÀÎ Full ScanÀÎ °æ¿ì
        ÀûÀýÇÑ Index ScanÀ¸·Î À¯µµÇØ¾ß ÇÑ´Ù

#

select /*+ ordered use_hash(c) swap_join_inputs(c) */ s.sid, s.program "Program",
    sum(decode(c.name, 'table fetch by rowid', a.value)) "Index Scan",
    sum(decode(c.name, 'table scan rows gotten',a.value)) "Full Scan",
    decode(sum(decode(c.name, 'table fetch by rowid', a.value))+sum(decode(c.name, 'table scan rows gotten',a.value)),0,
    -1, round(sum(decode(c.name, 'table fetch by rowid', a.value))/
    (sum(decode(c.name, 'table fetch by rowid', a.value))+sum(decode(c.name, 'table scan rows gotten',a.value)))*100,2)) "Index Scan Ratio"
from v$session s, v$sesstat a, v$statname c
where c.name in ( 'table scan rows gotten', 'table fetch by rowid' )
      and a.statistic# = c.statistic#
      and s.sid = a.sid
      and s.type != 'BACKGROUND'
      and s.module <> 'Orange for ORACLE'
group by s.sid, s.program
order by 5
/

doc
MTS
#

select value
from
sys.v_$parameter where name = 'mts_servers'
/

doc
OPS
#

select value
from
v$option where parameter IN ('Parallel Server', 'Real Application Clusters')
/

spool off


¸ñ·Ï | ÀÔ·Â | ¼öÁ¤ | ´äº¯ | »èÁ¦