Professional Documents
Culture Documents
To compare performance from one day, week, or year to the next, there must be multiple
snapshots taken over a period of time. The best method to gather snapshots is to automate the
collection at regular time intervals.
The spauto.sql script makes use of dbms_job, the automated method for
collecting statistics. The supplied script schedules a snapshot every hour, on the hour.This
can be changed to suit the requirements of the system.
Producing a Report
To examine the change in statistics between two time periods, execute the spreport.sql
file while being connected to the Perfstat user. The user is shown a list of collection
periods and selects a start and end period. The difference between the statistics at each end
point is then calculated and put into a file named by the user.
STATSPACK Output
The report generated by STATSPACK is similar to that of utlbstat and utlestat, but
there are many areas in which STATSPACK is better. The first page summary found with
STATSPACK aids the DBA, because there is now no need to search through the report to
determine these important numbers.
STATSPACK also assists in giving information about the SQL statements that are stored in
the shared SQL area, thus giving the DBA or developer better information about which
statements to tune in order to best use his or her time.
Wait events are also ordered by time so as to put the most problematic events at the top.
STATSPACK also attempts to put those wait events which are not a problem (for example,
pmon timer) at the end of the list, regardless of what the time value is.
SQL Statements
Several different ordered lists are given. SQL statements are sorted in order of number of
executions, number of parse calls, number of buffer gets, number of reads. By ordering the
SQL statements by these different columns, it is easier to determine which statements are
causing the heavy work load. These statements should then be tuned first, so as to get the
highest return on time spent.
These utilities:
• Gather performance figures over a defined period
• Produce a hard-copy report
To use these:
• Set TIMED_STATISTICS to TRUE
• Use the utlbstat.sql and utlestat.sql scripts
• Run the scripts from SQL*Plus connected as
SYSDBA
STATSPACK provides clearer statistics.
List of Events
There are more than 286 wait events in the Oracle server, including:
• Free Buffer Wait
• Latch Free
• Buffer Busy Waits
• Db File Sequential Read
• Db File Scattered Read
• Db File Parallel Write
• Undo Segment Tx Slot
• Undo Segment Extension
For the complete list, refer to the Oracle9i Reference, Release 9.0.1, Appendix A.
Performance Manager
Performance Manager is not a part of the basic Oracle Enterprise Manager that is shipped
with the database. Rather it is a part of an optional package.
Performance Manager Characteristics
The Performance Manager application captures, computes, and presents performance data in
a graphical, real-time view that allows you to monitor the key metrics required to:
• Use memory effectively
• Minimize disk I/O
• Avoid resource contention
The data displayed in real-time mode can be recorded for replay.
You can also define new charts and display windows containing charts in many categories.
Predefined Charts
Seven different categories of predefined charts are available for display. Each category has a
set of specific charts that focus on the parent subject.
I/O
These charts include File I/O Rate, File I/O Rate Details, Network I/O Rate, and System I/O
Rate.
Collect data
Analyze data
Review recommendations
Implement recommendations
Oracle Expert
Oracle Expert is not a part of the basic Oracle Enterprise Manager that is shipped with the
database. Rather it is a part of an optional package.
Methodology
Oracle Expert provides automated performance tuning with integrated rules. It automates:
• Collecting data
• Analyzing data
• Generating recommendations
• Creating scripts for recommendations implementation
In-House Scripts
The utilities and Oracle tools may not provide all the statistics you need.
Therefore, you can create your own scripts to do the following:
• Check for free space in every data file
• Determine whether segments have enough space to be able to extend
• Describe schema structures to show tables and associated indexes
• Use Oracle-supplied packages (created by $ORACLE_HOME/rdbms/
admin/dbms*.sql scripts) (refer to the Oracle Database Administration course for
more information)
Tuning Goal
In an OLTP environment, reparsing should be minimized.
• If an application makes a parse call for a SQL statement and the parsed representation
of the statement does not already exist in a shared SQL area in the library cache, the
Oracle server parses the statement and allocates a shared SQL area.
• Ensure that SQL statements can share a shared SQL area whenever possible, by using:
– As much generic code as possible
– Bind variables rather than constants
• If an application makes an execute call for a SQL statement, and the shared SQL area
containing the parsed representation of the statement has been deallocated from the
library cache to make room for another statement, the Oracle server implicitly reparses
the statement, allocates a new shared SQL area for it, and executes it. Reduce library
cache misses on execution calls by allocating more memory to the library cache.
• If a schema object is referenced in a SQL statement and that object is later modified in
any way, the SQL statement held in memory is rendered invalid.
Three Keywords
Each row in V$LIBRARYCACHE contains statistics for one type of item kept in the library
cache. The item described by each row is identified by the value of the NAMESPACE column.
Rows of the table with the following NAMESPACE values reflect library cache activity for SQL
statements and PL/SQL blocks: SQL AREA, TABLE/PROCEDURE, BODY, and TRIGGER.
Rows with other NAMESPACE values reflect library cache activity for object definitions that the
server uses for dependency maintenance: INDEX, CLUSTER, OBJECT, and PIPE.
Three keywords related to the namespace are:
• GETS shows the total number of requests for information on the corresponding item.
• PINS: For each of these areas, PINS shows the number of executions of SQL statements
or procedures.
• RELOADS: If an execute call for a SQL statement is performed and the shared SQL area
containing the parsed representation of the statement has been deallocated from the library
cache to make room for another statement or because the objects the statement refers to
have been invalidated, the Oracle server implicitly reloads the statement and therefore
reparses it. The number of reloads is counted for each of these namespaces.
V$DB_OBJECT_CACHE UGA
• report.txt output: This section indicates the same ratio for the period when
utlbstat and utlestat ran.
SQL statements:
SQL> select sum(sharable_mem)
2 from V$SQLAREA where executions > 5;
SUM(SHARABLE_MEM)
-----------------
381067
UGA
• OPEN_CURSORS
• CURSOR_SPACE_FOR_TIME
• SESSION_CACHED_CURSORS
Initialization Parameters
The following parameters also affect the library cache:
• OPEN_CURSORS: This parameter defines the number of cursors referencing private
SQL areas allocated to the user’s process. A private SQL area continues to exist until
the cursor is closed and therefore still exists after the completion of the statement.
To take advantage of additional memory available for shared SQL areas, you may need
to increase the number of cursors permitted for a session. Application developers should
close unneeded open cursors to conserve system memory. The default value is 50.
• CURSOR_SPACE_FOR_TIME: This is a boolean parameter that defaults to FALSE. If
you set it to TRUE, you choose to use space to gain time; shared SQL areas are not
aged out until the cursor referencing them is closed. Therefore, make sure that there is
free memory and no cache misses. Do not change this parameter unless the value of
RELOADS in V$LIBRARYCACHE is consistently 0. If your application uses Forms, or
any dynamic SQL, leave the setting at FALSE.