oracle系统性能指标(sysmetric)

v$sysmetric and v$sysmetric_history

Oracle Tips by Burleson Consulting

Oracle 10g v$sysmetric and v$sysmetric_history

Database workload metrics describe different aspects of database workload activity. Two examples are the number of calls per second and the physical reads per transaction. These metrics help the DBA monitor the database and estimate how effectively it operates at any given moment in time, and the v$sysmetric_history , v$sysmetric , and v$sysmetric_summary dynamic performance views allow us access to information about these metrics.

 

As we see, the AWR captures snapshots of v$sysmetric_history which are available through the dba_hist_sysmetric_history view.

 

One great benefit of the v$sysmetric_history view is that it helps monitor the database workload in real time. It is very simple to build real time charts based on this view. For example, the Ion tool provides such functionality as the plotting of real time charts for metrics with both short and long durations. The example in Figure 7.2 shows how Ion monitors metrics in real time:

 

Figure 7.2:  Monitoring workload database metrics in real time using Ion.

 

Using a visual representation of database workload, it is simple to find correlations between the behaviors of database workload metrics and wait events that are caused by database processing. For example, if there are high values for log file switch completion or log file sync wait events, it is worth the DBA’s time to view the workload for the Redo Generated Per Second metric in order to estimate the impact of the redo workload on these wait events.

 

The v$sysmetric view is similar to the v$sysmetric_history view, but it reports metric values for only the most current time sample. Both long and short duration metrics are available in the v$sysmetric view.

 

The v$sysmetric_summary view is also similar to the v$sysmetric_history view, but it has additional columns and it displays such summary information as minimum, maximum, and average values of database metrics as well as their standard deviations. These summary values are computed for the number of sample intervals included in the num_intervals column. The v$sysmetric_summary view reports data only for database metrics that belong to the System Metrics Long Duration metric group. This view can be used to build alert reports. For example, the following metric_values.sql query shows database metrics that have more than 15 percent growth in their current value compared to average value:

 

<     metric_values.sql

 

 

SELECT

  to_char(m.begin_time,'hh24:mi') "start time",

  to_char(m.end_time,'hh24:mi')   "end time",

  m.value                         "current value",

  s.average                       "average value",

  m.metric_name,

  m.metric_unit

FROM

  v$sysmetric         m,

  v$sysmetric_summary s

WHERE

SEE CODE DEPOT FOR FULL SCRIPTS

  AND s.average > 0   

  AND ((m.value - s.average)/s.average)*100 >= 10

  AND lower(m.metric_name) NOT LIKE '%ratio%';

 

 

The following output shows the current and average values for metrics of interest to the DBA:

 

Start End T Curr Val Avg Val METRIC_NAME            METRIC_UNIT

----- ----- -------- ------- ---------------------- -----------------------

15:42 15:43       29      18 User Calls Per Txn     Calls Per Txn

15:42 15:43       63      31 Rows Per Sort          Rows Per Sort

15:42 15:43        5       3 CPU Usage Per Sec      CentiSeconds Per Second

15:42 15:43      294     180 CPU Usage Per Txn      CentiSeconds Per Txn

15:42 15:43       29      26 Current Logons Count   Logons

15:42 15:43      301     225 Response Time Per Txn  CentiSeconds Per Txn

15:42 15:43       17      15 Process Limit %        % Processes/Limit

15:42 15:43       18      16 Session Limit %        % Sessions/Limit

15:42 15:43        5       3 Database Time Per Sec  CentiSeconds Per Second

15:43 15:43       21      18 User Calls Per Txn     Calls Per Txn

15:43 15:43        7       3 Database Time Per Sec  CentiSeconds Per Second

 

Using the above script output, the DBA is able to identify the database metrics that have significantly changed from their average values. This report can point a DBA to some exceptional activity occurring in the database.

 

The AWR also takes snapshots for the v$sysmetric_summary view that are available through the dba_hist_sysmetric_summary view.

 

It is also possible to monitor database metrics on a per session basis. The v$sessmetric view contains a single row per current session and reports the following metrics:

§      CPU usage by session.

§      Number of physical reads.

§      PGA memory consumption.

§      Numbers of hard and soft parses.

§      Physical and logical read ratios.

Using this view, database sessions can be monitored for extra resource consumption. For example, the cpu_hot_sessions.sql query below returns a list of sessions which consume CPU time more than one percent of total database CPU time:

 

<     cpu_hot_sessions.sql

 

select

   s.sid,

   s.username

FROM

  v$sessmetric sm,

  v$session    s

WHERE

      s.sid = sm.session_id

AND

   (sm.cpu/(SELECT decode(value,0,-1)

    FROM

       v$sysmetric

    WHERE

 SEE CODE DEPOT FOR FULL SCRIPTS

 

The output of this query might look like:

 

SID    USERNAME

------ --------------------------

33     SCOTT

19     SYSTEM

 

Using the above output, a DBA is able to quickly identify sessions consuming extra CPU resources.

 

Now that database metrics used to describe database workload activity have been introduced, it is time to look at the metrics available in Oracle10g that show times database was waiting for something.

你可能感兴趣的:(oracle系统性能指标(sysmetric))