|
 |
|
Oracle Concepts - Dynamic Performance
v$ Views
Oracle Tips by Burleson Consulting |
The Oracle Dynamic Performance v$ Views
In this section we will discuss the Dynamic Performance
Views. These views are very helpful in monitoring your database for real time
performance. In this section we will cover the following:
* The purpose of the Dynamic Performance Views
* The architecture of the Dynamic Performance Views
* Uses of the Dynamic Performance Views
Here is a
description of some of the Oracle x$ tables
and sample queries against the x$ table structures. You can
also grep your $ORACLE_HOME/rdbms/admin directory and see how
the x$ structures are mapped to v$ views.
Also see the
x$ kernel service & cache table.
For a map of the important data on the v$ views
that are built from the Oracle x$ tables, see this
Oracle Poster.
The purpose of the Dynamic Performance Views
The dynamic performance views (we will call them the V$
views to shorten the name) are real-time or almost real time views into the guts
of Oracle. What is the difference between the data dictionary views and the V$
Views? You can think of the data dictionary views like a parts manual…. It lists
all the parts of the car, and shows you pictures of where they are located. This
is handy if you want to know where something is, or if you need to replace a
part, but not so helpful when you want to adjust the timing of the car.
The V$ Views are like the speedometer and the tachometer
in your car, they tell you how fast the car (or the database) is going (or not),
or like the timing light that helps you adjust the timing. They provide almost
immediate feedback as to the condition of the database.
The architecture of the Dynamic Performance Views
The basic foundation of the Dynamic Performance Views is
a set of very low level Oracle views you should rarely if ever need to access….
These views are called the X$ views. The X$ views are very low level
representations of Oracle internal database structures. They are not tables, but
database representation of C structures that are maintained by the Oracle
kernel.
The naming conventions of the X$ views and the columns
in these views is such that you don’t want to have to go looking in the X$
views, trust me. Be happy you don’t need to access these things.
Lying on top of the X$ views, Oracle has created a very
complete set of views called the V_$ views. Oracle then provides synonyms that
have the V$ names that point to the V_$ views (we discussed synonyms earlier in
this book, recall they are used to provide pointers to other things in the
database). Hence, in the end when we want access to real time database
information, it’s the V$ synonyms that we will use (but we call them V$ views,
go figure!).
One last thing to note is that only those with DBA
privileges have access to the V$ views. There are ways around this, but it
requires some rather advanced DBA work. You will just need to do some research
to find your answer.
Uses of the V$ Views
As with the earlier section on the Data Dictionary
Views, we felt it would be worthwhile to provide some examples of the use of the
V$ views.
Again, the whole idea here is to get you to thinking
about using the V$ views to monitor your databases performance. In the end,
there are a ton of scripts out on the internet that you can find that will do
just about whatever you need. Hence, here are some example uses of the V$ views:
* See who is on the system
* See what SQL users are running on the system
* See what session is blocking other session
* See what waits are occurring in your database.
Viewing current Oracle users
One thing DBA’s want to know is who is on the system.
The following query is a good introduction to the V$ views. It uses the
v$session view to show you who is currently connected to the database.
SQL>
select sid, serial#, username, osuser, machine from v$session
2 where
username is not NULL;
SID SERIAL# USERNAME OSUSER MACHINE
---------- ---------- ------------------------- ----------
-------------------
122 49671 GRUMPY grummy htmldb.com
141 45178 IMPORTANT_STUFF oracle htmldb.com
Notice in the results of this query the SID and SERIAL#
columns. These columns individually identify each user session. The USERNAME
columns shows us the Oracle username of the person signed into the system, and
the OSUSER column shows us the OS username that the person is signed into the
client as. These two columns can be very handy when trying to figure out who is
actually connected to your system. For example, if I’m on a UNIX system we can
run the finger command on the GRUMPY user, and we might well find out GRUMPY’s
identity:
SQL> host
finger grumpy
Login:
grumpy Name: Mike Dwarf Sr.
Directory: /home/grumpy Shell: /bin/bash
On since
Mon Sep 5 21:30 (EDT) on pts/4 from c-67-163-49-102.hsd1.il.comcast.net
No mail.
No Plan.
Here we find that Grumpy is actually Mike Dwarf Sr. If
Mike isn’t supposed to be on the system, we might be making a phone call right
about now.
There are a number of these V$ views in Oracle,
providing a wealth of information. You can find them documented in the Oracle
Database 10g Reference Guide.
This is an excerpt from the bestselling "Easy
Oracle Jumpstart" by Robert Freeman and Steve Karam (Oracle ACE and Oracle
Certified Master). It’s only $19.95 when you buy it directly from the
publisher
here.
 |
If you like Oracle tuning, you may enjoy the new book "Oracle
Tuning: The Definitive Reference", over 900 pages of BC's favorite tuning
tips & scripts.
You can buy it direct from the publisher for 30%-off and get instant access to
the code depot of Oracle tuning scripts. |
|