by 구루비스터디 동적성능뷰 V$PARAMETER v$osstat v$sess_time_model v$event_name [2023.09.08]
v$ 뷰 | 단일 인스턴스 동적 성능 뷰 |
gv$ 뷰 | RAC에서의 글로벌 동적 성능 뷰 / v$뷰와 구조 동일, inst_id 칼럼으로 인스턴스 구별 |
SQL> SELECT NAME, VALUE FROM V$PARAMETER WHERE NAME = 'timed_statistics';
NAME VALUE
----------------- ------------------------------
timed_statistics TRUE
>>> 시간 정보 사용 가능
SQL> SELECT NAME, VALUE FROM V$PARAMETER WHERE NAME = 'statistics_level';
NAME VALUE
------------------ ------------------------------
statistics_level TYPICAL
>>> TYPICAL 또는 ALL 이면 timed_statistics의 기본값이 TRUE
- 위 두 파라미터 값을 변경하는 것은 비권장
SQL> SELECT * FROM v$osstat;
STAT_NAME VALUE OSSTAT_ID COMMENTS CUMULATIVE
--------------------------- --------- --------- ---------------------------------------------------------------- ----------
NUM_CPUS 16 0 Number of active CPUs NO
IDLE_TIME 6.3e+009 1 Time (centi-secs) that CPUs have been in the idle state YES
BUSY_TIME 91748353 2 Time (centi-secs) that CPUs have been in the busy state YES
USER_TIME 63104850 3 Time (centi-secs) spent in user code YES
SYS_TIME 28643121 4 Time (centi-secs) spent in the kernel YES
IOWAIT_TIME 6448213 5 Time (centi-secs) spent waiting for IO YES
AVG_IDLE_TIME 394451646 7 Average time (centi-secs) that CPUs have been in the idle state NO
AVG_BUSY_TIME 5608914 8 Average time (centi-secs) that CPUs have been in the busy state NO
AVG_USER_TIME 3818665 9 Average time (centi-secs) spent in user code NO
AVG_SYS_TIME 1664826 10 Average time (centi-secs) spent in the kernel NO
AVG_IOWAIT_TIME 313373 11 Average time (centi-secs) spent waiting for IO NO
OS_CPU_WAIT_TIME 283519300 13 Time (centi-secs) processes spent on the run queue to be schedul YES
RSRC_MGR_CPU_WAIT_TIME 620 14 Time (centi-secs) processes spent in the runnable state waiting YES
LOAD 6.0e-001 15 Number of processes running or waiting on the run queue NO
NUM_CPU_CORES 4 16 Number of CPU cores NO
NUM_VCPUS 4 18 NO
NUM_LCPUS 16 19 NO
PHYSICAL_MEMORY_BYTES 3.3e+010 1008 Physical memory size in bytes NO
VM_IN_BYTES 1.0e+013 1009 Bytes paged in due to virtual memory swapping YES
VM_OUT_BYTES 1.5e+012 1010 Bytes paged out due to virtual memory swapping YES
TCP_SEND_SIZE_MIN 4096 2000 TCP Send Buffer Min Size NO
TCP_SEND_SIZE_DEFAULT 16384 2001 TCP Send Buffer Default Size NO
TCP_SEND_SIZE_MAX 9.2e+018 2002 TCP Send Buffer Max Size NO
TCP_RECEIVE_SIZE_MIN 4096 2003 TCP Receive Buffer Min Size NO
TCP_RECEIVE_SIZE_DEFAULT 16384 2004 TCP Receive Buffer Default Size NO
TCP_RECEIVE_SIZE_MAX 9.2e+018 2005 TCP Receive Buffer Max Size NO
GLOBAL_SEND_SIZE_MAX 4194304 2006 Global send size max (sb_max) NO
GLOBAL_RECEIVE_SIZE_MAX 4194304 2007 Global receive size max (sb_max) NO
1) background elapsed time
2) background cpu time
3) RMAN cpu time (backup/restore)
1) DB time
2) DB CPU
2) connection management call elapsed time
2) sequence load elapsed time
2) sql execute elapsed time
2) parse time elapsed
3) hard parse elapsed time
4) hard parse (sharing criteria) elapsed time
5) hard parse (bind mismatch) elapsed time
3) failed parse elapsed time
4) failed parse (out of shared memory) elapsed time
2) PL/SQL execution elapsed time
2) inbound PL/SQL rpc elapsed time
2) PL/SQL compilation elapsed time
2) Java execution elapsed time
2) repeated bind elapsed time
SQL> SELECT * FROM v$sess_time_model WHERE sid = 3;
SID STAT_ID STAT_NAME VALUE
--------- --------- ---------------------------------------------------------------- ---------
3 3.6e+009 DB time 3367885
3 2.7e+009 DB CPU 2280000
3 4.2e+009 background elapsed time 0
3 2.5e+009 background cpu time 0
...
3 1.3e+009 PL/SQL compilation elapsed time 5186
3 751169994 Java execution elapsed time 0
3 1.2e+009 repeated bind elapsed time 411
3 2.4e+009 RMAN cpu time (backup/restore) 0
--세션이 시작된 이후 처리에 얼마나 많은 시간을 사용 했는지 보여주는 쿼리
SQL> WITH db_time AS (SELECT sid, value
FROM v$sess_time_model
WHERE sid = 3
AND stat_name ='DB time')
SELECT ses.stat_name AS statistic
,round(ses.value / 1E6, 3) AS seconds
,round(ses.value / nullif(tot.value, 0) * 1E2, 1) AS "%"
FROM v$sess_time_model ses, db_time tot
WHERE ses.sid = tot.sid
AND ses.stat_name <> 'DB time'
AND ses.value > 0
ORDER BY ses.value DESC;
STATISTIC SECONDS %
---------------------------------------------------------------- --------- ---------
DB CPU 2.28 67.7
sql execute elapsed time 1.029 30.5
parse time elapsed 0.59 17.5
PL/SQL execution elapsed time 0.142 4.2
hard parse elapsed time 0.117 3.5
hard parse (bind mismatch) elapsed time 0.091 2.7
hard parse (sharing criteria) elapsed time 0.091 2.7
connection management call elapsed time 0.019 0.6
PL/SQL compilation elapsed time 0.005 0.2
repeated bind elapsed time 0 0
SQL> SELECT * FROM v$event_name WHERE rownum < 12;
EVENT# EVENT_ID NAME PARAMETER1 PARAMETER2 PARAMETER3 WAIT_CLASS_ID WAIT_CLASS# WAIT_CLASS
--------- --------- ---------------------------------------------------------------- ---------------------------------------------------------------- ---------------------------------------------------------------- ---------------------------------------------------------------- ------------- ----------- ----------------------------------------------------------------
0 2.5e+009 null event 1.9e+009 0 Other
1 3.5e+009 pmon timer duration 2.7e+009 6 Idle
2 3.9e+009 logout restrictor 3.9e+009 4 Concurrency
3 939791390 VKTM Logical Idle Wait 2.7e+009 6 Idle
4 1.5e+009 VKTM Init Wait for GSGA 2.7e+009 6 Idle
5 1.4e+009 IORM Scheduler Slave Idle Wait 2.7e+009 6 Idle
6 1.2e+009 Parameter File I/O blkno #blks read/write 1.7e+009 8 User I/O
7 866018717 rdbms ipc message timeout 2.7e+009 6 Idle
8 3.2e+009 remote db operation clientid operation timeout 2.0e+009 7 Network
9 2.2e+009 remote db file read clientid count intr 2.0e+009 7 Network
10 538064841 remote db file write clientid count intr 2.0e+009 7 Network
SQL> SELECT wait_class, count(*)
FROM v$event_name
GROUP BY rollup(wait_class)
ORDER BY wait_class;
WAIT_CLASS COUNT(*)
--------------------- ---------
Administrative 55
Application 17
Cluster 50
Commit 2
Concurrency 33
Configuration 24
Idle 95
Network 35
Other 736
Queueing 9
Scheduler 8
System I/O 30
User I/O 48
1142
v$system_wait_class | 시스템 레벨의 대기 이벤트 클래스 |
v$session_wait_class | 세션에 대한 대기 이벤트 클래스 |
wait_class | 대기 클래스 구분 |
total_waits | 데이터베이스 인스턴스, 세션, 컨테이너(12c)가 시작된 이후 대기 이벤트의 누적 발생 횟수 |
time_waited | 데이터베이스 인스턴스, 세션, 컨테이너(12c)가 시작된 이후 대기시간을 1/100초 단위로 누적한 것 |
SQL> SELECT wait_class
, round(time_waited, 3) AS time_waited
, round(1E2 * ratio_to_report(time_waited) OVER (), 1) as "%"
FROM (
SELECT sid, wait_class, time_waited / 1E2 AS time_waited
FROM v$session_wait_class
WHERE total_waits > 0
UNION ALL
SELECT sid, 'CPU', value / 1E6
FROM v$sess_time_model
WHERE stat_name = 'DB CPU'
)
WHERE sid = 3
ORDER by 2 DESC;
WAIT_CLASS TIME_WAITED %
---------------------------------------------------------------- ----------- ---------
Idle 4.1e+006 100
CPU 2.28 0
User I/O 0.08 0
Network 0.04 0
SQL> SELECT event
, round(time_waited, 3) AS time_waited
, round(1E2 * ratio_to_report(time_waited) OVER (), 1) as "%"
FROM (
SELECT sid, event, time_waited_micro / 1E6 AS time_waited
FROM v$session_event
WHERE total_waits > 0
UNION ALL
SELECT sid, 'CPU', value / 1E6
FROM v$sess_time_model
WHERE stat_name = 'DB CPU'
)
WHERE sid = 3
ORDER by 2 DESC;
EVENT TIME_WAITED %
---------------------------------------------------------------- ----------- ---------
SQL*Net message from client 4.1e+006 100
CPU 2.28 0
db file sequential read 0.077 0
SQL*Net message to client 0.038 0
Disk file operations I/O 0 0
SQL> SELECT TRUNC(time_waited_micro/total_waits/1E3, 6) AS avg_wait_ms
FROM v$system_event
WHERE event = 'db file sequential read';
AVG_WAIT_MS
-----------
0.037143
SQL> SELECT wait_time_milli, wait_count, TRUNC(100 * ratio_to_report(wait_count) OVER (), 2) AS "%"
FROM v$event_histogram
WHERE event = 'db file sequential read';
WAIT_TIME_MILLI WAIT_COUNT %
--------------- ---------- ---------
1 359996708 99.77
2 572332 0.15
4 188217 0.05
8 51696 0.01
16 9444 0
32 1422 0
64 1094 0
128 1097 0
256 310 0
512 43 0
1024 1 0
2048 4 0
4096 1 0
8192 1 0
SQL> SELECT * FROM v$sysstat WHERE ROWNUM < 12;
STATISTIC# NAME CLASS VALUE STAT_ID
---------- ---------------------------------------------------------------- --------- --------- ---------
0 OS CPU Qt wait time 1 0 576270482
1 logons cumulative 1 502463 2.7e+009
2 logons current 1 197 3.1e+009
3 opened cursors cumulative 1 2.1e+009 85052502
4 opened cursors current 1 606 2.3e+009
5 user commits 1 6084531 582481098
6 user rollbacks 1 10626 3.7e+009
7 user calls 1 124811076 2.9e+009
8 recursive calls 1 2.6e+009 2.7e+009
9 recursive cpu usage 1 26504057 4.0e+009
10 pinned cursors current 1 161 2.8e+009
-- 데이터베이스 인스턴스가 시작된 이후의 로그온 횟수, 커밋 획수, 메모리 내 정렬 횟수
SQL> SELECT name, value
FROM v$sysstat
WHERE name IN ('logons cumulative', 'user commits', 'sorts (memory)');
NAME VALUE
---------------------------------------------------------------- ---------
logons cumulative 502471
user commits 6084571
sorts (memory) 68256921
-- 디스크 I/O 오페레이션을 통해 처리된 데이터의 양
SQL> SELECT name, value
FROM v$sysstat
WHERE name LIKE 'physical % total bytes';
NAME VALUE
---------------------------------------------------------------- ---------
physical read total bytes 1.8e+013
physical write total bytes 1.4e+012
--현재 할당된 PGA 메모리 크기, 세션이 생성된 후 할당된 PGA 메모리 최대 크기
SQL> SELECT sn.name, ss.value
FROM v$statname sn, v$sesstat ss
WHERE sn.statistic# = ss.statistic#
AND sn.name LIKE 'session pga memory%'
AND ss.sid = sys_context('userenv', 'sid');
NAME VALUE
---------------------------------------------------------------- ---------
session pga memory 27459480
session pga memory max 36962200
- 강좌 URL : http://www.gurubee.net/lecture/4339
- 구루비 강좌는 개인의 학습용으로만 사용 할 수 있으며, 다른 웹 페이지에 게재할 경우에는 출처를 꼭 밝혀 주시면 고맙겠습니다.~^^
- 구루비 강좌는 서비스 제공을 위한 목적이나, 학원 홍보, 수익을 얻기 위한 용도로 사용 할 수 없습니다.