DBMS
DBMS, September 1996
Server Side By Martin Rennhackkamp

Performance Monitoring

A primer on performance monitoring, and what leading DBMS vendors have to offer

In my previous mini-series I investigated the mechanisms you can use to ensure that you have only correct data in your databases. Correct data is not of much use, however, if you cannot get to it in finite time. Your databases will only be useful if your users can get to the data quickly and easily. In this month's column I start a new mini-series focusing on performance. Performance management can be divided into three related disciplines:
performance estimation, performance measurement, and performance improvement. I will cover only the technical topics of performance measurement ("monitoring") and performance improvement ("tuning") and leave the highly theoretical topic of performance estimation for the academic journals. This month I investigate performance monitoring in general, including the performance monitoring facilities provided by five popular DBMSs. Next month I will look at some of the mechanisms available to improve performance.

Performance Goals

The goal of performance management is to give users the fastest possible access to their required data while using the available resources as efficiently and effectively as possible. These resources typically include processing space, processing time, and human time. Processing space refers to memory and disk space, processing time refers to CPU and I/O times, and human time refers to the real response times experienced by the users.

Most databases - no matter how well-designed - are prone to bad performance at one stage or another. This happens when, as the saying goes, "entropy sets in." Entropy, a well-known concept encountered in physics, is described as the tendency toward chaos. Sometimes in database applications entropy doesn't "set" in - it actually "rushes" in. An example of rushing occurs when you keep inserting linear key values into a non-self-balancing tree structure: One branch of the tree keeps growing while the other branches stay the same or even shrink, resulting in a skewed tree structure and terrible performance. Other examples of rushing occur when hashed or clustered indexes get long overflow chains that increase locking contention; when there is an unplanned change in the transaction rates and volumes; or when there are changes to the information stored, large volumes of new information, new access paths to the stored data, or changes in the typical usage patterns.

Several other factors besides entropy can influence a database's performance significantly. These factors include how and where the DBMS is installed, how the DBMS server is configured, how and where the logging and locking functions are performed, and - most important - the designs of the databases and the database applications.

Monitoring

Shaku Atre, in her textbook Data Base: Structured Techniques for Design, Performance and Management (John Wiley & Sons, 1980), wrote: "To design a database and hope that it will forever remain constant is a very naive outlook. Even the best physical design cannot provide constantly good performance for a volatile database, despite the self-reorganizing features of some DBMSs." These words still ring true, even after 16 years in our fast-changing industry. Therefore, one of the important tasks of a DBA is to detect when the database system needs improvement. To resolve this situation, DBAs must monitor their database environments closely to obtain quantitative evaluations of their system's performance. DBAs can then use these quantities in statistics or compare them to each other to detect trends and changes.

Although I discuss monitoring in the context of performance management, it is important to note that monitoring is also a good problem-avoidance mechanism. For example, by constantly monitoring disk usage, a wide-awake DBA can avoid the potential problems caused by a full disk by moving some data to an emptier disk before the disk fills completely.

Monitoring Tools

There are several tools you can use to monitor database performance. These can be classified as:

CA-OpenIngres

CA-OpenIngres 1.2 provides a number of facilities that can be used for performance monitoring. These tools include Interactive Performance Monitor (IPM), trace points, Visual DBA, and Ingres Management Architecture (IMA).

IPM is used to monitor the DBMS server processes and the locking and logging systems. For each server process, IPM shows the user sessions making use of that process, including what queries they are performing, which facility in the DBMS the queries are being processed by, and other related transaction details. For each user, IPM shows how many locks are being used, which tables and resources are locked, and the locks for which the user is waiting. For the logging system, IPM shows how often the log file is being accessed, the transactions for which it is being used, and how it is drained by the journaling system.

Trace points are variables that can be set to print tracing information to the screen or to a log file. Two of the most useful trace points are "set qep" and "set qe90." The first trace point gives you the query execution plan (QEP) selected by the optimizer for each query, while the second compares the actual execution statistics with the estimated statistics on the query execution plan. There are literally hundreds of other trace points that can be used for performance monitoring. Some of these can even influence the way the statistics-based query optimizer makes its decisions.

The QEP used to analyze the performance of the following query is shown in Figure 1:

SET qep;
SELECT M.MvTitle, M.YrMde, M.MvType, D.DirName
FROM MOVIE M, DIRECTOR D
WHERE M.DirNumb = D.DirNumb;
COMMIT;
Visual DBA is a GUI-based DBMS installation and database management tool. Although it is mostly used for database management tasks, it has some facilities for performance monitoring as well. For example, it can show statistics about selected databases, selected tables, or selected columns of the selected tables.

IMA provides a programmable way to monitor and manage CA-OpenIngres installations. With IMA you can use any SQL- or ODBC-based tool to view or update the monitoring information about the CA-OpenIngres servers in your installation. For example, from a normal application program, you can query which sessions are holding locks required by other sessions. You can monitor specific database metrics and depict the results as a graph to understand specific performance trends.

Borland InterBase

InterBase 4.1 has two facilities for monitoring performance: the InterBase Server Manager and the InterBase Interactive SQL Interface. The InterBase Server Manager displays database server statistics and lock manager statistics of the currently connected database. The database server statistics include transaction ID generation statistics, database file statistics, and log file statistics. The lock statistics include details on locks requested, granted, and released by the various transactions operating on the database. Lock statistics also show deadlock scans, deadlocks detected, and mutually exclusive deadlock waits. All of these statistics are displayed as log files in a notepad-like window.

The InterBase Interactive SQL Interface has various useful settings for performance monitoring. The "set stats on" setting displays the server's memory utilization, the query's elapsed time, the buffer utilization, and the number of physical disk read and write operations. The "set plan on" setting displays how queries are physically executed, specifically showing index utilization. Listing 1 shows a query and its query plan.

Microsoft SQL Server

Microsoft SQL Server 6.0 is tightly integrated with the Windows NT operating system. This integration increases the extent to which the Windows NT Performance Monitor is used to monitor the components of the SQL Server installation. It can monitor SQL Server's internal details (such as cache, I/O, read-ahead, locking, and logging details) and user and replication details. For each user, the CPU time used, the locks held, the memory utilized, and the physical I/O performed can be monitored.

Various objects (or so-called instances of objects) can be monitored. Information from various machines in the network can even be displayed simultaneously in one monitor session. This is shown in Figure 2, where the legend depicts which objects are being monitored.

DBAs can also use the SQL Enterprise Manager to monitor and manage any number of SQL Server installations on the network. Among other things, SQL Enterprise Manager can report the size of any database or device on the network. It can also schedule monitoring, management, or tuning tasks via the SQL Executive. For example, the Current Activity option in the SQL Enterprise Manager produces the screen shown in Figure 3. This screen displays a quick overview of the current activity in the system and can identify a problem. In this case, the user "Cor" is being blocked by the user "sa" on the dbo.CargoItems resource. You can inspect a particular job by double-clicking on it. You can use the options on the Current Activity Screen to view the same information from other angles; for example, the Detail Activity option gives the activity per process (thread) in the server in a tabular format.

Developers and DBAs can use the query analysis tools available in ISQL/W, the GUI-interactive SQL environment provided as part of the client SQL Server installation. This lets users test the syntax, semantics, and performance of their SQL queries. This test is performed by activating the Query Plan and Statistics I/O options before running the query. You can also choose to optimize the query without running it, which will let you inspect a large query plan without actually running it.

Oracle

Oracle7.2 provides three utilities to help DBAs monitor performance: the dynamic performance views, the SQL trace facility, and the explain plan command. In addition, Oracle7.2 on Windows NT is closely integrated with the Windows NT Performance Manager, which also provides a multitude of performance statistics.

Dynamic performance views are a set of underlying "tables" maintained by the Oracle server. These tables are continuously updated while a database is open and in use; their contents relate primarily to performance. To access these tables, the DBA must log on with the user name "SYS." Although they appear to be regular database tables, these tables may never be updated or altered; they may only be queried using SQL select statements. They present information such as the objects in the database that are currently locked and the sessions that are accessing them, a list of all the data files making up the database, and a list of all the database objects cached in the library cache.

The SQL trace facility generates performance statistics on the SQL statements executed by the Oracle server. These statistics include parse, execute, and fetch counts, CPU and elapsed times, physical and logical reads, and the number of rows processed. When the SQL trace facility is enabled, the performance statistics for all of the SQL statements executed in a user session or against the instance are placed into a trace file.

The explain plan command displays the execution plan chosen by the Oracle server's optimizer for SQL select, update, insert, and delete statements. The execution plan depicts the sequence of operations on the database objects that Oracle performs. By examining execution plans, you can investigate index utilization. However, before you can issue the explain plan statement, you must create a table of a specific structure to hold its output. The execution plan is then inserted into the table when a corresponding SQL statement is executed. Although the execution plan is not shown graphically, the table format is useful for extracting and summarizing performance data using SQL.

Centura SQLBase

SQLBase's SQLConsole utility provides a wealth of useful performance monitoring information through a consistent, easy-to-use GUI interface. From SQLConsole you can monitor the SQLBase DBMS servers, the various SQLBase databases, the open cursors, the status of the locking system, and the server parameters, as well as various alarms and events. For the SQLBase DBMS servers you can view activity and process information. The performance monitoring information is displayed in Windows screens, which can be captured with any popular screen-grabbing package and printed (although you can't copy them to the clipboard). The performance monitoring information (as shown in Figure 4) can be refreshed automatically at specified intervals, or you can refresh it manually when required.

SQLBase also has a large number of so-called "environment options" that can be activated or deactivated. Some of these can be useful for performance monitoring; for example, the planonly environment option can be used to display the execution strategy followed by SQLBase in an easy-to-read table format.

Back to the Basics

The scientists that taught us about entropy also talk about the Heisenberg uncertainty principle, which loosely means that the act of observing something introduces new elements that alter what is observed. One of the problems with performance monitoring is that the tools used to monitor the performance can themselves affect the performance adversely. For example, a monitor that constantly polls the disk subsystem for disk usage details itself affects the disk usage, specifically if it stores the monitoring details on disk. The effects of the monitor on the mTING Rennhackkamp is the owner and principal consultant of The Data Base Approach, a corporation specializing in relational and distributed databases, based in Cape Town, South Africa. You can reach Martin via the Internet at mr@dba.co.za.


* Borland International Inc., 100 Borland Way, Scotts Valley, CA 95066; 800-245-7367 or fax 408-431-4122; http://www.borland.com.
* Centura Software Corp., 1060 Marsh Rd., Menlo Park, CA 94025; 800-444-8782, 415-617-8500, or fax 415-321-5471; http://www. centurasoft.com.
* Computer Associates International Inc., One Computer Associates Plaza, Islandia, NY 11788; 800-225-5224, 516-342-5224, or fax 516-342-5734; http://www.cai.com.
* Microsoft Corp., One Microsoft Way, Redmond, WA 98052; 800-426-9400, 206-882-8080, or fax 206-936-7329; http://www.microsoft.com.
* Oracle Corp., 500 Oracle Pkwy., Redwood Shores, CA 94065; 800-672-2537, 415-506-7000, or fax 415-506-7200; http://www.oracle.com.

FIGURE 1


--A QEP in CA-OpenIngres.


FIGURE 2


--A monitoring session screen from the Windows NT Performance Monitor.


FIGURE 3


--The Current Activity option in the SQL Enterprise Manager.


FIGURE 4


--The SQLBase database monitoring screen.


LISTING 1

SET PLAN ON;
SELECT R.RegionName, C.CustomerName, AC.AccountNo,
I.InvoiceNo, I.Balance
FROM REGION R, AREA A, CUSTOMER C, ACCOUNT AC, INVOICE I
WHERE A.RegionName = R.RegionName and
AC.AreaName = A.AreaName and
AC.CustomerNo = C.CustomerNo and
I.AccountNo = AC.AccountNo and
I.Balance >= 0
ORDER BY 1, 2, 3;
PLAN JOIN (R NATURAL,
A INDEX (RDB$FOREIGN3,AREAFKIDX),
AC INDEX (RDB$FOREIGN7,ACCOUNTFK2IDX),
C INDEX (RDB$PRIMARY4),
I INDEX (RDB$FOREIGN9,INVOICEFKIDX))

--A query and its query plan generated by the InterBase Interactive SQL Interface.


Table of Contents - September 1996 | Home Page
Copyright © 1996 Miller Freeman, Inc. ALL RIGHTS RESERVED
Redistribution without permission is prohibited.
Please send questions or comments to mfrank@mfi.com
Updated Friday, September 20, 1996