
Monitoring Views & Tuning a Parallel Server
This chapter describes how to monitor performance of a parallel server by querying data dictionary views and dynamic performance views. It also explains how to tune a parallel server.
Monitoring Data Dictionary Views with CATPARR.SQL
The SQL script CATPARR.SQL creates parallel server data dictionary views. To run this script, you must have SYSDBA privileges and
either log in with the SYS username or use the CONNECT INTERNAL command.
Run the CATPARR.SQL script after creating or modifying database objects and allocating storage for them, not when you create the database. Do not include CATPARR.SQL in the value of the initialization parameter INIT_SQL_FILES, which specifies SQL scripts such as CATALOG.SQL to run at database creation.
CATALOG.SQL creates the standard V$ dynamic views, as described in the "Data Dictionary Reference" chapter of Oracle7 Server Reference.
You should rerun CATPARR.SQL to update the information about database objects in the views after making any structural changes to
the database, or after the Oracle Server allocates new extents to database objects.
Note: If you drop objects without rerunning CATPARR.SQL, the views may display misleading information about those database objects.
The following data dictionary views are available to monitor a
parallel server:
See Also: "Dynamic Performance & Monitoring Views"
for descriptions of the data dictionary views.
Oracle7 Server Reference for more information on dynamic views and monitoring your database.
Monitoring Dynamic Performance Views
This section covers the following topics:
The V$ Views
The following dynamic views are available to monitor a parallel server:
V$BH
|
V$CACHE
|
V$CACHE_LOCK
|
V$FALSE_PING
|
V$LOCK_ACTIVITY
|
V$LOCK_ELEMENT
|
V$PING
|
The V$ views are accessible to the user with SYSDBA privileges or a DBA user connected as INTERNAL. You can grant PUBLIC access to
V$ views by running the script MONITOR.SQL, or you can grant individual users SELECT access to new views based on the dynamic views, as described in the "Data Dictionary Reference" chapter of Oracle7 Server Administrator's Guide.
The V$BH, V$CACHE, and V$PING views contain statistics about the frequency of PCM lock conversion due to contention between instances. Each row in these views represents one block in the buffer cache of the current instance.
The COUNTER Column
In the V$LOCK_ACTIVITY view, the COUNTER column shows the number of times each type of PCM lock conversion has occurred since the instance started up.
The XNC Column
In the V$BH, V$CACHE, and V$PING views, the XNC column shows the number of times the PCM lock covering that block has converted from X (exclusive) to NULL at the request of another instance since the block entered the buffer cache. XNC therefore indicates the amount of contention for data. If the PCM lock covers a set of blocks, some or all
of the lock conversions could be caused by requests for other blocks in that set.
Each block starts with an XNC value of zero when it first enters the buffer cache. This value is incremented whenever the instance releases the PCM lock covering that block. If a PCM lock covers multiple blocks, they can have different values of XNC because they may enter the buffer cache at different times.
Note: A single block can appear in multiple rows of the V$BH, V$CACHE, and V$PING views. Each row represents a different copy (version) of the block. Multiple versions created for read-consistent queries appear with the status CR. For tuning purposes, you only need consider the current copy (status XCUR or SCUR) that contains the greatest value of XNC.
When an instance writes a block to disk and reuses that buffer for other data, XNC is reset to zero. If the block returns to the buffer cache while other versions of that block are still in the cache, it starts with the greatest value of XNC for any version of the same block, rather than starting with zero.
Null Values
Null values appear in rows for distributed locks on temporary segments, such as sort blocks. Null values can also appear in some rows of the dynamic views after you create or modify database objects, or after the Oracle Server allocates new extents to database objects; in this case, you should update the views by rerunning CATPARR.SQL.
Use the following procedure to monitor and tune the distributed lock activity in a parallel server.
Querying V$LOCK_ACTIVITY to Monitor Instance Lock Activity
The V$LOCK_ACTIVITY view lists the frequencies of various types of PCM lock conversions for all buffers in the SGA of the current instance; it does not contain information about particular blocks, files, or
database objects.
This section covers the following topics:
Analyzing V$LOCK_ACTIVITY
You should periodically query the V$LOCK_ACTIVITY view for each instance of a parallel server. The Server Manager command CONNECT @instance-path allows you to specify an instance before querying its dynamic performance views. SQL*Net must be installed to use the CONNECT command for an instance on a remote node. When analyzing the V$LOCK_ACTIVITY view, note that:
- Many PCM locks are initially converted when an instance
is started.
- Rapid increases in the number of lock conversions in successive queries (for example, increments of 500+) indicate contention problems on the system.
- Excessive lock conversions (for example, exceeding 5,000 per minute) indicate contention problems on the system.
For example, the query
SELECT * FROM V$LOCK_ACTIVITY;
could display these rows:
FROM TO ACTION COUNTER
---- ---- -------------------------------------------------- -------
NULL S Lock buffers for read 5953
NULL X Lock buffers for write 1118
S NULL Make buffers CR (no write) 6373
S X Upgrade read lock to write 2077
X NULL Make buffers CR (write dirty buffers) 1
X S Downgrade write lock to read (write dirty buffers) 3164
X SSX Write transaction table/undo blocks 1007
SSX NULL Transaction table/undo blocks (write dirty buffers) 2
SSX S Make transaction table/undo block available share 1
SSX X Rearm transaction table write mechanism 1007
See Also: Your platform-specific Oracle documentation for information about connecting with SQL*Net.
Monitoring and Tuning Lock Activity
Use the following procedure to control distributed lock activity.
To Monitor and Tune Instance Lock Activity
1. Repeatedly query each instance that you want to monitor with the following SQL statement:
SELECT * FROM V$LOCK_ACTIVITY;
2. If this increases rapidly for any instance, identify the types
of lock conversions that are most active in the instance with the following SQL statement:
SELECT * FROM V$LOCK_ACTIVITY;
3. Query the V$LOCK_ACTIVITY view of each instance to identify
which instances have the most NULL to S conversions or S to X conversions. These instance are making most of the requests for data that is locked by other instances ("pinging").
If pinging occurs on several instances at approximately the same rate, you may need to tune your PCM lock allocations (see Step 7)
or you may have a set of data that the instances access equally, in which case you need to tune your applications (see Step 8).
SELECT * FROM V$PING;
You might want to restrict this query with a qualifier to display the blocks that have undergone the most contention; for example:
SELECT * FROM V$PING WHERE XNC > 100;
SELECT FILE#, BLOCK#, MAX(XNC) FROM V$PING
GROUP BY FILE#, BLOCK#;
Note: Querying V$BH is faster than querying V$PING or V$CACHE. You can query V$BH to find the block numbers and file numbers of interest, then query V$CACHE for the particular blocks to find out what database objects contain them.
5. For blocks that show high rates of pinging, compare FILE# with the datafiles specified in GC_FILES_TO_LOCKS to find out whether their PCM locks cover multiple blocks. If so, also note whether the locks cover blocks in multiple files.
6. If the PCM locks cover multiple blocks, you should determine whether other instances require data from the same block or from different blocks in the same set. To do this, query V$CACHE (or V$BH) in other instances for the BLOCK# that corresponds to a high value of XNC in the instance you are monitoring.
7. If the block does not appear in another instance, there is unnecessary contention (false pinging) because instances that require different blocks are using the same PCM lock for those blocks.
If you know a block gets pinged, check the class of the block to see which initialization parameter should be changed. Query V$CACHE and V$BH to get the class number, then refer to "Initialization Parameters Which Control PCM Locks"
to look up its class. If a pinged block is class 1, for example, you should change the GC_FILES_TO_LOCKS and GC_DB_LOCKS parameters. If a block is class 4, change GC_SEGMENTS.
To minimize unnecessary contention within one or more datafiles, reduce the number of blocks per lock by allocating more PCM locks to the files with the GC_FILES_TO_LOCKS parameter. (If you increase the number of locks in GC_FILES_TO_LOCKS, you must also increase the value of GC_DB_LOCKS.)
If the PCM locks cover multiple files, you can reduce contention by allocating separate sets of locks to individual files.
8. If the same blocks show up in multiple buffer caches, the instances are contending for the same data.
When multiple instances frequently need to modify data in the same block, you may be able to improve performance by running the applications that require the data on the same instance.
Note: Contention for data blocks and other shared resources does not necessarily have a significant effect on performance. If the response time of your applications is acceptable and you do not anticipate substantial increases in system usage, you may not need to tune your parallel server.
See Also: "Dynamic Performance Views"
for a description of each view.
Querying the V$PING View to Detect Pinging
Use the following procedure to detect "pings"--that is, to identify the database objects that have PCM lock conversions.
To Detect Pinging
SQL> SELECT NAME, FILE#, CLASS#, MAX(XNC) FROM V$PING
2 GROUP BY NAME, FILE#, CLASS#
3 ORDER BY NAME, FILE#, CLASS#;
NAME FILE# CLASS# MAX(XNC)
------------ -------- ------ ---------
...
DEPT 8 1 492
DEPT 8 4 10
EMP 8 1 3197
EMP 8 4 29
...
2. Query V$PING again to display the frequency of PCM lock conversions and information for blocks in file 8.
SQL> SELECT * FROM V$PING WHERE FILE# = 8;
FILE# BLOCK# STAT XNC CLASS# NAME KIND
------ ------ ---- ----- ------ -------------- -------
8 98 XCUR 450 1 EMP TABLE
8 764 SCUR 59 1 DEPT TABLE
3. Query the EMP table to display the rows contained in block 98. Convert the BLOCK# to a hexadecimal value and compare it to the ROWID. (98 equals 62 in hexadecimal.)
SQL> SELECT ROWID, EMPNO, ENAME FROM EMP
2 WHERE chartorowid(rowid) like '00000062%';
ROWID EMPNO ENAME
------------------ ------ ----------
00000062.0000.0008 12340 JONES
00000062.0000.0008 6491 CLARK
....;
Querying the V$WAITSTAT View to Monitor Contention
Use this view to display block contention statistics for resources such as rollback segments and free lists.
This section covers the following topics:
Monitoring Contention for Blocks in Free Lists
Use the following procedure to monitor contention for blocks in free lists.
To Monitor Contention for Blocks in Free Lists
1. To check the number of waits for free blocks in free lists:
SQL> SELECT CLASS, COUNT FROM V$WAITSTAT
2 WHERE CLASS = 'free list';
CLASS COUNT
------------------ -------
free list 12
2. Compare the COUNT obtained with total number of requests (SUM) for data over the same period.
SQL> SELECT SUM(VALUE) FROM V$SYSSTAT
2 WHERE name IN
3 ('db block gets', 'consistent gets');
SUM (VALUE)
------------
12050211
If the number of waits for free blocks (COUNT) is greater than 1% of the total requests (SUM), consider adding more free lists to tables to reduce contention.
SQL> CREATE TABLE new_emp
2 STORAGE (FREELISTS 5)
3 AS SELECT * FROM emp;
Table created.
SQL> DROP TABLE emp;
Table dropped.
SQL> RENAME new_emp TO emp;
Table renamed.
Monitoring Contention for Rollback Segments
Use the following procedure to monitor contention for rollback segments.
To Monitor Contention for Rollback Segments
1. Determine contention for rollback segments with the V$WAITSTAT view.
SQL> SELECT CLASS, COUNT
2 FROM V$WAITSTAT
3 WHERE CLASS IN ('system undo header',
4 'system undo block','undo header','undo block');
CLASS COUNT
------------------ -------
system undo header 12
system undo block 11
undo header 28
undo block 6
2. Compare the COUNT obtained with total number of requests (SUM) for data over the same period.
SQL> SELECT SUM(VALUE) FROM V$SYSSTAT
2 WHERE name IN
3 ('db block gets', 'consistent gets');
SUM (VALUE)
------------
12050211
See Also: "Data Dictionary Reference" chapter in Oracle7 Server Reference.
Querying V$FILESTAT to Monitor I/O Activity
Use the V$FILESTAT view to monitor statistics on disk/file access and determine the greatest I/O activity in the system.
To Query the V$FILESTAT View
1. To determine the number of reads and writes to each database file and the name of each datafile, query the V$FILESTAT and
V$DATAFILE views.
SQL> SELECT NAME, PHYRDS, PHYWRTS
2 FROM V$DATAFILE df, V$FILESTAT fs
3 WHERE df.file# = fs.file#;
NAME PHYRDS PHYWRTS
------------------------- ----------- ----------
/test71/ora_system.dbs 7679 2735
/test71/ora_system1.dbs 32 546
2. To determine the number of reads and writes to each non-database file, use an operating system utility, such as the UNIX utility iostat. The total I/O for each disk is the total number of reads and writes to all files on the disk.
- Separate datafiles and redo log files on different disks.
- Separate (or stripe) table data on different disks.
- Separate tables and indexes on different disks.
- Reduce disk I/O not related to the Oracle server.
4. Analyze the statistics from the V$FILESTAT view to determine whether files need to be placed on separate disks to avoid contention for disk I/O.
- Place frequently accessed datafiles on separate disks to allow multiple processes to access the data with less contention.
- Place each set of redo log files on a separate disk with little activity. Information in a redo log file is written sequentially; writing can take place much faster if there is no concurrent activity on the same disk.
Note: Consult your hardware documentation to determine disk I/O limits. Any disks operating at or near full capacity are potential sites for disk contention. For example, 40 or more I/Os per second is excessive for most disks on VMS or UNIX operating systems.
Querying and Interpreting V$SESSTAT and V$SYSSTAT Statistics
The V$SESSTAT and V$SYSSTAT views provide parallel statistics for monitoring contention for various resources including data blocks, rollback segment blocks, and free space lists. This section describes how to query and interpret these statistics.
To Display System Statistics
1. To display system statistics for analyzing your parallel server (class = 32 or class = 40), issue the following command:
SQL> SELECT * FROM V$SYSSTAT WHERE CLASS = 32 OR CLASS = 40;
STATISTIC# NAME CLASS VALUE
---------- -------------------------------------- ----- --------
28 global lock gets (non async) 32 225663
29 global lock gets (async) 32 169023
30 global lock get time 32 23199
31 global lock converts (non async) 32 773052
32 global lock converts (async) 32 93488
33 global lock convert time 32 65636
34 global lock releases (non async) 32 381994
35 global lock releases (async) 32 0
36 global lock release time 32 13637
59 DBWR cross instance writes 40 230
60 remote instance undo writes 40 0
61 remote instance undo requests 40 255
62 cross instance CR read 40 24
69 next scns gotten without going to DLM 32 0
73 calls to get snapshot scn kcmgss 32 349
74 kcmsss waited for batching 32 0
75 kcmgss reads scn without going to DLM 32 0
84 hash latch wait gets 40 1
18 rows selected.
The following tips will help you interpret statistics obtained from these views.
global lock converts (async) Divide this number by the V$SYSSTAT statistic "user commits" to calculate the percentage of
cache hits.
DBWR cross-instance writes
This value equates to the number of blocks pinged. For large values, reallocate locks based on
V$PING statistics.
remote instance undo writes
A large value may signify pinging activity.
remote instance undo requests
A large value indicates that data modified by this instance if often read by another instance; locate applications (and thus transactions) contending for the same data on the same instance.
cross-instance CR read
This is a slow read because every instance has to write out the block; a large value indicates that the instance is spending too much time waiting on blocks modified by other instances. Evaluate the distribution of locks in the GC_FILES_TO_LOCKS parameter and reallocate to keep the value of this statistic small.
next scns gotten without going to DLM
Divide this value by the total number of SCN gets given by the "user commits" statistic to calculate the percentage of SCN gets satisfied from the cache and thus measure the effectiveness of a parallel server's SCN cache.
hash latch wait gets
If this value is large or rapidly increasing, increase the number of hash latches.
kcmgss waited for batching
An internal call to get a snapshot might have to wait (for an on-going fetch of a SCN to complete) before contacting the distributed lock manager. This statistic value indicates system load and the number of opportunities that Oracle has to batch a single get-snapshot-SCN with other SCN fetches.
kcmgss reads scn without going to DLM
If an internal call (to get a snapshot SCN) waits for an on-going SCN fetch, it may use the SCN acquired by the SCN fetch, thus avoiding overhead in using the distributed lock manager.
The ratio of "kcmgss reads scn without going to DLM" and "kcmgss waited for batching" indicates the effectiveness of the parallel server's SCN
batch algorithm.
See Also: Oracle7 Server Reference for definitions of these statistics.
Oracle Server Manager User's Guide descriptions of the MONITOR STATISTICS CACHE display for information about monitoring contention for various kinds of blocks.