In my opinion, the single most important new feature of Oracle9i is the ability to dynamically modify almost all of Oracle’s performance parameters. This lets an Oracle professional dynamically reconfigure the Oracle instance while it's running, whether in reaction to a current performance problem or in anticipation of an impending performance demand. Because everything within the System Global Area (SGA)—the RAM used by an instance of Oracle—can now be modified dynamically, it's critical for you to understand how to monitor your Oracle database. When you learn to recognize trends and patterns within your system, you can proactively reconfigure the database in anticipation of regular resource needs.
With respect to ongoing database tuning activities, an Oracle expert will generally look at two areas: normally scheduled reconfiguration to support regularly scheduled changes in processing requirements, and trend-based dynamic reconfiguration made in response to information gained from STATSPACK. Let’s examine how Oracle supports both of these activities.
Consider an Oracle database that runs in Online Transaction Processing (OLTP) mode during the day and in Decision Support mode at night. These two tasks have very different requirements for optimal performance. For this type of database, the Oracle DBA can schedule a job to reconfigure the Oracle instance to the most appropriate configuration for the current type of processing.
You’ll generally use one of two tools for scheduling a dynamic reconfiguration. The most common approach is to use a UNIX cron job that launches a shell script to schedule a periodic reconfiguration. You could also use the Oracle dbms_job utility. Either of these tools will allow you to schedule a configuration change.
In Listing A you’ll find a UNIX script that can be used to reconfigure Oracle for decision support processing. Note that the script makes changes to the shared_pool, db_cache_size, and pga_aggregate_target parameters to accommodate data warehouse activity. A similar script could then be run in the morning to change the database configuration back to OLTP mode.
Trend-based dynamic reconfiguration
When performing trend-based dynamic reconfiguration, you’ll collect historical data about the Oracle database and use this information to proactively reconfigure the database, perhaps by using the dbms_job package to fire ad-hoc changes or by scheduling regular reconfiguration using one of the methods I discussed. This is analogous to just-in-time manufacturing—where goods appear on the manufacturing floor at just the time they are needed in the assembly process—in that an Oracle DBA can anticipate processing needs and ensure that the SGA resources are delivered in time to accommodate processing tasks.
You can use STATSPACK to track signatures for important metrics and reveal patterns to predict the resources that your Oracle servers will need. Metric signatures are usually collected by hour of the day and by day of the week, making it easy to discover these patterns. For example, consider the hour of the day plot of the data buffer hit ratio (BHR) that appears in Figure A.
|This BHR plot shows a recurring shortage of buffer blocks.|
Notice that the repeating signature seems to indicate a shortage of data buffer blocks between the hours of 2:00 and 3:00 A.M. and again between 8:00 and 9:00 P.M. Once you know this, you can schedule tasks to reallocate RAM to the data buffers during these time periods to alleviate the problem.
You can also plot the data BHR by day of the week, as you can see in Figure B. From the graph, you can see problems on Monday and Friday, indicating that you need to increase the db_cache_size for those days to correct the problem.
|A daily BHR plot can illustrate problems over a longer cycle.|
Trend-based information is a gold mine for the Oracle DBA because it can be used to reveal previously unseen performance trends within an Oracle database. In my next article, I’ll take a closer look at the metrics used by savvy Oracle professionals to determine how to dynamically tune their Oracle9i databases.