Oracle動態效能檢視學習筆記(2)_v$sesstat_v$mystat_v$statname
參考文件<
##################################################################
1 Overview
##################################################################
1.1 v$sesstata stores session-specific resource usage statistics, beginning at login and ending at logout.
統計會話級的統計資料。雖然是會話級的,但並不是說只有當前會話,是所有會話都有統計。
1.2 The differences between v$sysstat and sesstat:
1) v$sesstat only stores data for each session, whereas v$sysstat stores the accumulated values for all session.
(系統級與會話級)
2) v$sesstat is transitory, and is lost after a session logs out. v$sysstat is cumulative, and is only lost when the instance is shutdown.
3) v$sesstat does not include the name of the statistic, this view must be joined to either v$sysstat or v$statname.
##################################################################
2 示例
##################################################################
2.1 Finding the Top sessions with Highest Logical and Physical I/O Rates Currently Connected to the database.
查詢當前Session消耗IO最多的會話。
SQL> select name, statistic#
2 from v$statname
3 where name in( 'session logical reads', 'physical reads');
NAME STATISTIC#
---------------------------------------------------------------- ----------
session logical reads 9
physical reads 42
SQL> SELECT ses.sid
2 ,DECODE(ses.action,NULL,'online','batch') "User"
3 , MAX(DECODE(sta.statistic#,9,sta.value,0))/greatest(3600*24*(sysdate-ses.logon_time),1) "Log IO/s"
4 , MAX(DECODE(sta.statistic#,42,sta.value,0))/greatest(3600*24*(sysdate-ses.logon_time),1) "Phy IO/s"
5 , 60*24*(sysdate-ses.logon_time) "Minutes"
6 FROM V$SESSION ses , V$SESSTAT sta
7 WHERE ses.status = 'ACTIVE'
8 AND sta.sid = ses.sid
9 AND sta.statistic# IN (9,42)
10 GROUP BY ses.sid, ses.action, ses.logon_time
11 ORDER BY
12 SUM( DECODE(sta.statistic#,42,100*sta.value,sta.value) )/ greatest(3600*24*(sysdate-ses.logon_time),1) DESC;
SID User Log IO/s Phy IO/s Minutes
---------- ------ ---------- ---------- ----------
4 online 0 .035992199 5144.63333
5 online .944926428 .011179935 5144.63333
28 online .793103448 0 .966666667
7 online .601633417 3.2396E-06 5144.63333
2 online 0 .000187898 5144.63333
3 online 0 .000187898 5144.63333
6 online .001755875 3.2396E-06 5144.63333
1 online 0 0 5144.65
8 rows selected
2.2:又例如透過v$sesstat和v$statname連線查詢某個SID各項資訊。
select a.*,b.name
from v$sesstat a,v$statname b
where a.statistic#=b.statistic#
and a.sid=12 order by a.value desc;
##################################################################
3 v$mystat
##################################################################
This view is a subset of v$sesstat returning current session's statistics. When auditing resource usage for sessions through triggers, use v$mystat to capture
the resource usage, because it is much cheaper than scanning the rows in v$sesstat.
v$mystat是v$sesstat的子集,當透過觸發器來捕捉資料時,用v$mystat 成本比v$sesstat更低。
##################################################################
4 v$statname
##################################################################
This view displays decoded statistic names for the statistics shown in the v$sesstat and v$sysstat tables.
On some platforms, the name and class columns contain additional operating system-specific statistics.
SQL> desc v$statname;
Name Type Nullable Default Comments
---------- ------------ -------- ------- --------
STATISTIC# NUMBER Y
NAME VARCHAR2(64) Y
CLASS NUMBER Y
SQL> select count(name) from v$statname;
COUNT(NAME)
-----------
272
總共有272個statname.
具體每個name的含義參考官方文件<
其中272個name共分成如下8大類別.
CLASS NUMBER A number representing one or more statistics classes. The following
class numbers are additive:
1 - User
2 - Redo
4 - Enqueue
8 - Cache
16 - OS
32 - Real Application Clusters
64 - SQL
128 - Debug
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10248702/viewspace-669512/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle動態效能檢視學習筆記(1)_v$sysstatOracle筆記
- Oracle動態效能檢視學習筆記(3)_v$undostatOracle筆記
- Oracle動態效能檢視學習筆記(4)_v$rollstatOracle筆記
- Oracle動態效能檢視學習筆記(6)_v$filestatOracle筆記
- Oracle動態效能檢視學習筆記(7)_v$sessionOracle筆記Session
- Oracle動態效能檢視學習筆記(4)_v$waitstatOracle筆記AI
- Oracle動態效能檢視學習筆記(8)_v$waitstatOracle筆記AI
- Oracle動態效能檢視學習筆記(9)_v$system_eventOracle筆記
- Oracle動態效能檢視學習筆記(10)_v$session_waitOracle筆記SessionAI
- Oracle動態效能檢視學習之v$sqltext & v$sqlareaOracleSQL
- (轉)Oracle動態效能檢視學習之v$processOracle
- Oracle動態效能檢視學習之 V$ROLLSTAT -- 轉Oracle
- Oracle動態效能檢視學習之v$lock & v$locked_objectOracleObject
- (轉)Oracle動態效能檢視學習之V$DB_OBJECT_CACHEOracleObject
- (轉):學習Oracle動態效能表-(2)-V$SQLTEXTOracleSQL
- Oracle效能優化視訊學習筆記-動態調整SGAOracle優化筆記
- V$PGASTAT動態效能檢視AST
- 學習oracle動態效能表--v$transactionOracle
- oracle學習筆記——檢視、索引Oracle筆記索引
- Oracle檢視:常用動態效能檢視Oracle
- 學習動態效能表(四)-(2)-V$SQLAREASQL
- 學習動態效能表(八)-(2)-v$lock
- (轉)Oracle 動態效能檢視Oracle
- 動態檢視V$SESSION_LONGOPS學習SessionGo
- oracle 學習筆記---效能優化(2)Oracle筆記優化
- Oracle動態效能檢視之v$session_longops ztOracleSessionGo
- Oracle的v$動態檢視 收藏Oracle
- (轉):學習Oracle動態效能表-(7)-V$SQLTEXT,V$SQLAREAOracleSQL
- [轉]學習Oracle動態效能表-(6)-V$SQLTEXT,V$SQLAREAOracleSQL
- (轉):學習Oracle動態效能表-(12)-V$PROCESSOracle
- (轉):學習Oracle動態效能表-(10)-V$FILESTATOracle
- (轉):學習Oracle動態效能表-(8)-V$SESSIONOracleSession
- (轉):學習Oracle動態效能表-(5)-V$SESSTATOracle
- (轉)學習Oracle動態效能表-(4)-V$SYSSTATOracle
- (轉):學習Oracle動態效能表-(1)-V$SQLAREAOracleSQL
- (轉):學習Oracle動態效能表-(21)-V$UNDOSTATOracle
- (轉):學習Oracle動態效能表-(19)-v$rowcacheOracle
- (轉):學習Oracle動態效能表-(18)-V$ROLLSTATOracle