1 일반적인 대기 이벤트

1. 목적

  • 성능저하의 원인이 DB 서버인지 Application 서버인지, 서버의 어느 자원인지의 판별

2. 서버 자원 여유 점검

  • Sar, vmstat, 작업관리자 등으로 DB 서버와 Application 서버의 여유율 점검

        $> vmstat -t 60 1000
	
	    kthr    memory              page              faults        cpu       time
	    ----- ----------- ------------------------ ------------ ----------- --------
	    r  b   avm   fre  re  pi  po  fr   sr  cy  in   sy  cs us sy id wa hr mi se
	    7 24 3132936  2000   0   0   0 5186 27716   0 5546 40941 14037 40  6  8 45 08:48:06
	    7 26 3137616  2062   0   1   0 7389 47361   0 5787 42744 17656 41  8  8 43 08:49:06
	    9 33 3145090  2081   0   1   0 7047 37573   0 5813 57915 20228 43  9  5 44 08:50:06
	    7 55 3140985  9712   0   1   0 9142 51835   0 8203 39344 20428 37  9  2 52 08:51:06
	    7 52 3152171  2001   0   1   0 8396 51356   0 7999 40604 20296 36  9  2 53 08:52:06

3. OS process 의 자원 점유율 식별

  • 목적 : 성능저하의 원인이 DB process 에 있는지 여부를 점검
  • 방법 : top, topas, nmon, 작업관리자 등으로 자원점유 상위 프로세스가 DB process 인지 확인

2. DB 성능 진단 방법

1. Wait Time 누적 치 점검

  • DB startup 시점부터 현재까지의 Batch 를 포함한 전체 성능 통계가 gathering 됨

SELECT *
FROM   V$SYSTEM_EVENT
WHERE  EVENT NOT IN ('rdbms ipc message', 
		   'smon timer', 
		   'pmon timer', 
		   'slave wait',
		   'pipe get', 
		   'null event', 
		   'SQL*Net message from client',
		   'SQL*Net message to client', 
		   'PX Idle Wait', 
		   'PX Deq: Execution Msg',
		   'KXFQ: kxfqdeq - normal deqeue', 
		   'ges remote message',
		   'wakeup time manager', 
		   'lock manager wait for remote message',
		   'single-task message', 
		   'PL/SQL lock timer')
ORDER  BY TIME_WAITED DESC;

EVENTTOTAL_WAITSTOTAL_TIMEOUTSTIME_WAITEDAVERAGE_WAITTIME_WAITED_MICRO
db file scattered read2258447829400212181881212181878128
buffer busy waits22584478294002121818841212181878128
latch free51260165087031192547644192547636520
enqueue545875223415791067289157910668926
SQL*Net more data to client696810101608363016083629190
db file sequential read5500370501086626010866256691
control file parallel write1155769043108004310799289
log file parallel write393075017958501795854562
log file sync2919541714427201442723748
  • 모니터링 툴 이용한 시구간 별 성능통계 분석
    • 모니터링툴의 logging 기능을 이용하여 시간대별 성능통계의 snapshot 분석
    • 상용화된 GUI 툴이나 Oracle Stats Pack 이용
  • Online 세션 점검
    • 현재시점의 실행중인 세션들의 wait event 분석
      • GUI 툴이나 script 이용

SELECT /*+ ORDERED */
       S.SID SID,
       S.SERIAL#,
       Q.SQL_TEXT,
       S.USERNAME "USER",
       S.PROGRAM,
       S.MODULE,
       S.LAST_CALL_ET DUR,
       P.SPID "OS-Pid",
       W.SECONDS_IN_WAIT AS "W_time(Sec)",
       W.STATE, -- 9i above
       W.ENAME EVENT,
       W.P1TEXT || ':' ||
       DECODE(W.EVENT, 'latch free', W.P1RAW, TO_CHAR(W.P1)) || ',' ||
       W.P2TEXT || ':' || TO_CHAR(W.P2) || ',' || W.P3TEXT || ':' ||
       TO_CHAR(W.P3) "Parameter"
FROM   (SELECT A.*,
               DECODE(A.EVENT,
                      'latch free',
                      'latch free (' || B.NAME || ')',
                      'row cache lock',
                      'row cache lock (' || C.PARAMETER || ')',
                      'enqueue',
                      'enqueue (' || CHR(BITAND(P1, -16777216) / 16777215) ||
                      CHR(BITAND(P1, 16711680) / 65535) || ':' ||
                      DECODE(BITAND(P1, 65535), 1, 'N',
                                                2, 'SS',
                                                3, 'SX',
                                                4, 'S',
                                                5, 'SSX',
                                                6, 'X') || ')',
                      A.EVENT) ENAME
        FROM   V$SESSION_WAIT A,
               V$LATCHNAME    B,
               V$ROWCACHE     C
        WHERE  A.P2 = B.LATCH#(+)
        AND    A.P1 = C.CACHE#(+)
        AND    C.TYPE(+) = 'PARENT'
        AND    A.EVENT NOT IN ('rdbms ipc message', 
                               'smon timer', 
                               'pmon timer',
                               'slave wait', 
                               'pipe get', 
                               'SQL*Net message from client',
                               'SQL*Net message to client', 
                               'PX Idle Wait',
                               'PX Deq: Execution Msg', 
                               'KXFQ: kxfqdeq - normal deqeue',
                               'ges remote message', 
                               'wakeup time manager',
                               'lock manager wait for remote message',
                               'single-task message', 
                               'PL/SQL lock timer',
                               'jobq slave wait', 
                               'queue messages')) W,
       V$SESSION S,
       V$PROCESS P,
       V$SQL Q
WHERE  W.SID = S.SID
AND    S.PADDR = P.ADDR
AND    S.SQL_HASH_VALUE = Q.HASH_VALUE(+)
AND    S.SQL_ADDRESS = Q.ADDRESS(+)
ORDER  BY S.LAST_CALL_ET DESC;

SIDSERIAL#SQL_TEXTUSERPROGRAMMODULEDUROS-PidW_timeSTATEEVENTParameter
5122808{code:SQL}
SELECT ROWNUM AS ID
, SUBSTR('15001852001001', 5, 3)

'9'

, '' AS MASTERID
'0' ||
JI.TOJI_SEQ ||
JI.TOJI_MOVE_SEQ ||
JI.O_NUM ||
JI.P_CHASU ||
, JI.SU_CHASU AS OBJECTID
, 'O' AS GUBUN
, '' AS CUSTKEY
, CS.P_SEQ ||
CS.TOJI_MOVE_SEQ ||
CS.P_SEQIN ||
CS.SO_KUBUN AS PID
, CS.P_NAME AS PNAME
, '' AS RID
, '' AS RNAME
, '' AS RIGHTS
, CS.P_JIBOON AS

|CMP|JDBC Thin Client|JDBC Thin Client|9|27560|9|WAITING|db file scattered read|file#:27,
block#:111707,
blocks:16|

    * Online 세션 점검
        ** DB 통계정보를 이용한 HIT 율 점검으로 DB Parameter 설정 점검

h1. 3. Top SQL 의 튜닝

*1. 목적*
    - 시스템에 부하를 많이 주거나 장시간 돌아간 SQL 이 SGA 에 cache 되어있는 동안 모니터링하여 튜닝

*2. 시스템에서 I/O Wait 비중이 높은 경우 Physical Read 를 많이 한 SQL 위주로 검출하여 튜닝*

*3. 시스템의 CPU 가 부족한 경우 Buffer Cache 를 많이 사용한 한 SQL 위주로 검출하여 튜닝*

*4. Shared Pool Latch Wait 이 많을 경우 Literal SQL 에 의한 Hard Parsing 을 발생시키는 SQL 을 검출하여 변수처리를 하여 SQL 이 공유되도록 튜닝*

*5. 자원이 여유 있는 상태에서 장시간 수행되는 SQL 튜닝*

{code:SQL}
SELECT SUBSTR(SQL_TEXT, 1, 30),
       MODULE,
       -- ACTION,
       -- PARSING_USER_ID,
       U.USERNAME,
       COUNT(*) SQL_NUM,
       SUM(EXECUTIONS) EXE,
       SUM(DISK_READS) DISK_READS,
       SUM(BUFFER_GETS) BUFFER_GETS,
       ROUND(SUM(BUFFER_GETS) / SUM(EXECUTIONS)) BUFF_PER_EXE,
       SUM(ROWS_PROCESSED) ROWS_PROCESSED,
       SUM(SHARABLE_MEM) SHAREABLE,
       SUM(ELAPSED_TIME) ETIME
FROM   V$SQLAREA A,
       ALL_USERS U
WHERE  A.PARSING_USER_ID = U.USER_ID
-- WHERE  SQL_TEXT LIKE '%select  *  from (select  inner_temp%'
-- AND    MODULE LIKE '%EPOPJ702%'
-- AND    USERNAME = 'PUBOWNER'
GROUP  BY SUBSTR(SQL_TEXT, 1, 30),
          MODULE,
          U.USERNAME
HAVING SUM(EXECUTIONS) > 0 
-- AND COUNT(*) = SUM(EXECUTIONS)
-- ORDER  BY 7 DESC -- BUFFER_GETS
ORDER  BY 8 DESC -- buff_per_exe

SUBSTR(SQL_TEXT,1,30)MODULEUSERNAMESQL_NUMEXEDISKBUFFERBUFF_PER_EXEROWSSHAREABLEETIME
SELECT A.STEP1CITIS_PROD111980935980935554115008113262728
select to_char(sysdate,:"SSYS131147885149295014717477247164189
SELECT A.STEP1 AS STEP1, A.SQL*PlusCITIS_PROD13471330504443501689934358621291087
SELECT gubun,code AS gubun_idCITIS_PROD191362402940267020713407015254069
SELECT count(**) as CNT FROM TCITIS_PROD1119061722541122541115882024910460
select so.user_id,CITIS_PROD1102181552181551922401226768
SELECT "DOC_NO","ENTRY_DT" FROCITIS_PROD1632634722857871279361384811342225
select * from tb200 where titTOAD 8.0.0.47CITIS_PROD17399404834578337202164660097
SELECT "ENTRY_ID","ENTRY_DT","CITIS_PROD1316480116663555545112681307780070363
SELECT doc_no,title,CITIS_PROD238367951803980747101721149669816101593

<별첨 - 1> Oracle Wait Interface 구성요소

<별첨 - 2> 일반적인 대기 이벤트

^ Oracle_Wait_Interface(Excel).xls

1 일반적인 대기 이벤트

1) buffer busy waits
2) control file parallel write
3) db file parallel read
4) db file parallel write
5) db file scattered read
6) db file sequential read
7) db file single write
8) direct path read
9) direct path write
10) enqueue
11) free buffer waits
12) latch free
13) library cache pin
14) library cache lock
15) log buffer space
16) log file parallel write
17) log file sequential read
18) log file switch(archiving needed)
19) log file switch(checkpoint incomplete)
20) log file switch completion
21) log file sync
22) SQL*Net message from client
23) SQL*Net message to client

1) buffer busy waits

2) control file parallel write

3) db file parallel read

4) db file parallel write

5) db file scattered read

6) db file sequential read

7) db file single write

8) direct path read

9) direct path write

10) enqueue

11) free buffer waits

12) latch free

13) library cache pin

14) library cache lock

15) log buffer space

16) log file parallel write

17) log file sequential read

18) log file switch(archiving needed)

19) log file switch(checkpoint incomplete)

20) log file switch completion

21) log file sync

22) SQL*Net message from client

23) SQL*Net message to client

2 오라클 RAC 환경에서 일반적인 대기 이벤트

1) global cache cr request
2) buffer busy global cache
3) buffer busy global cr
4) global cache busy
5) global cache null to x
6) global cache null to s
7) global cache s to x
8) global cache open x
9) global cache open s
10) row cache lock

1) global cache cr request

2) buffer busy global cache

3) buffer busy global cr

4) global cache busy

5) global cache null to x

6) global cache null to s

7) global cache s to x

8) global cache open x

9) global cache open s

10) row cache lock

문서에 대하여