Sunteți pe pagina 1din 26

Managing Database Performance

Copyright © 2009, Oracle. All rights reserved.


Objectives

After completing this lesson, you should be able to:


• Monitor the performance of sessions and services
• Describe the benefits of Database Replay

14 - 2 Copyright © 2009, Oracle. All rights reserved.


Tuning Activities

The three activities in performance management are:


• Performance planning
• Instance tuning
• SQL tuning

14 - 3 Copyright © 2009, Oracle. All rights reserved.


Performance Planning

• Investment options
• System architecture
• Scalability
• Application design principles
• Workload testing, modeling, and implementation
• Deploying new applications

14 - 4 Copyright © 2009, Oracle. All rights reserved.


Instance Tuning

• Have well-defined goals.


• Allocate memory to database structures.
• Consider I/O requirements in each part of the database.
• Tune the operating system for optimal performance of the
database.

14 - 6 Copyright © 2009, Oracle. All rights reserved.


Performance Tuning Methodology

The tuning steps:


• Tune from the top down. Tune:
1. The design
2. The application code
3. The instance
• Tune the area with the greatest potential benefit. Identify
and tune:
– SQL using the greatest resources
– The longest waits
– The largest service times
• Stop tuning when the goal is met.

14 - 7 Copyright © 2009, Oracle. All rights reserved.


Performance Monitoring

With Enterprise Manager:


• Performance overview
• Graphs of metrics and
details

14 - 8 Copyright © 2009, Oracle. All rights reserved.


Performance Tuning Data

Type of data gathered:


• Cumulative statistics:
– Wait events with time information
– Time model
• Metrics: Statistic rates
• Sampled statistics: Active session history
– Statistics by session
– Statistics by SQL
– Statistics by service
– Other dimensions

14 - 9 Copyright © 2009, Oracle. All rights reserved.


Optimizer Statistics Collection

• SQL performance tuning: Depends on collection of


accurate statistics
• Optimizer statistics:
– Object statistics
– Operating system statistics
• Ways to collect statistics:
– Automatically: Automatic Maintenance Tasks
– Manually: DBMS_STATS package
– By setting database initialization parameters
– By importing statistics from another database

14 - 10 Copyright © 2009, Oracle. All rights reserved.


Statistic Preferences: Overview
Optimizer Statement level
statistics
Table level
gathering DBA_TAB_STAT_PREFS
task Schema level

Database level

Global level
CASCADE DEGREE
ESTIMATE_PERCENT METHOD_OPT
NO_INVALIDATE GRANULARITY
PUBLISH INCREMENTAL
STALE_PERCENT

set_global_prefs

set_database_prefs

set_schema_prefs

set_table_prefs

gather_*_stats DBA

14 - 12 Copyright © 2009, Oracle. All rights reserved.


Using Statistic Preferences

• PUBLISH: Used to decide whether to publish the statistics


to the dictionary or to store them in a pending area before
• STALE_PERCENT: Used to determine the threshold level
at which an object is considered to have stale statistics.
The value is a percentage of rows modified since the last
statistics gathering.
• INCREMENTAL: Used to gather global statistics on
partitioned tables in an incremental way

exec dbms_stats.set_table_prefs('SH','SALES','STALE_PERCENT','13');

14 - 13 Copyright © 2009, Oracle. All rights reserved.


Setting Global Preferences
with Enterprise Manager

14 - 14 Copyright © 2009, Oracle. All rights reserved.


Oracle Wait Events

• A collection of wait events provides information


about the sessions or processes that had to wait or must
wait for different reasons.
• These events are listed in the V$EVENT_NAME view.

14 - 15 Copyright © 2009, Oracle. All rights reserved.


Instance Statistics

V$SYSSTAT V$SYSTEM_WAIT_CLASS V$SGASTAT


• statistic# • wait_class_id • pool
• name • wait_class# • name
• class • wait_class • bytes
• value • total_waits
• stat_id • time_waited

V$EVENT_NAME
V$SYSTEM_EVENT
• event_number
• event
• event_id
• total_waits
• name
• total_timeouts
• parameter1
• time_waited
• parameter2
• average_wait
• parameter3
• time_waited_micro
• wait_class

14 - 16 Copyright © 2009, Oracle. All rights reserved.


Monitoring Session Performance

14 - 18 Copyright © 2009, Oracle. All rights reserved.


Displaying Session-Related Statistics

V$STATNAME V$SESSTAT V$SESSION


• statistic# • sid • sid
• name • statistic# • serial#
• class • value • username
• command
• osuser
• seq#
• event#
V$SESSION_EVENT V$EVENT_NAME • event
• sid • event# • p1/2/3text
• event • name • p1/2/3
• total_waits • parameter1 • p1/2/3raw
• total_timeouts • parameter2 • wait_class
• time_waited • parameter3 • wait_time
• average_wait • seconds_in_wait
• max_wait • state
• time_waited_micro • ...
• event_id

14 - 19 Copyright © 2009, Oracle. All rights reserved.


Displaying Service-Related Statistics

For n-tier environments, because session statistics are not as


helpful, you can see service-level statistics in these views:
• V$SERVICE_EVENT: Aggregated wait counts and wait
times for each service, on a per event basis
• V$SERVICE_WAIT_CLASS: Aggregated wait counts and
wait times for each service on a wait class basis

14 - 20 Copyright © 2009, Oracle. All rights reserved.


Troubleshooting and Tuning Views

Instance/Database Disk
V$DATABASE V$DATAFILE
V$INSTANCE V$FILESTAT
V$PARAMETER V$LOG
V$SPPARAMETER V$LOG_HISTORY
V$SYSTEM_PARAMETER V$DBFILE
V$PROCESS V$TEMPFILE
V$BGPROCESS V$TEMPSEG_USAGE
V$PX_PROCESS_SYSSTAT V$SEGMENT_STATISTICS
V$SYSTEM_EVENT
Contention
Memory V$LOCK
V$BUFFER_POOL_STATISTICS V$UNDOSTAT
V$LIBRARYCACHE V$WAITSTAT
V$SGAINFO V$LATCH
V$PGASTAT

14 - 21 Copyright © 2009, Oracle. All rights reserved.


Dictionary Views

• The following dictionary and special views display object


statistics after use of the DBMS_STATS package:
– DBA_TABLES, DBA_TAB_COLUMNS
– DBA_CLUSTERS
– DBA_INDEXES
– DBA_TAB_HISTOGRAMS
• This statistical information is static until you reexecute the
appropriate procedures in DBMS_STATS.

14 - 22 Copyright © 2009, Oracle. All rights reserved.


Automatic Workload Repository

ADDM finds
MMON
top problems.

SYSAUX
SGA
6:00 AM
Snapshot 1
In-memory 7:00 AM
Snapshot 2
statistics 8:00 AM Snapshot 3
9:00 AM
Snapshot 4

9:30 AM

14 - 23 Copyright © 2009, Oracle. All rights reserved.


Using Automatic Workload Repository Views

• DBA_HIST_DB_CACHE_ADVICE
• DBA_HIST_DISPATCHER
• DBA_HIST_DYN_REMASTER_STATS
• DBA_HIST_IOSTAT_DETAIL
• DBA_HIST_SHARED_SERVER_SUMMARY

14 - 25 Copyright © 2009, Oracle. All rights reserved.


Real Application Testing Overview:
Database Replay
Database Replay:
• Captures production workloads
• Tests with realistic workloads
• Replays the same SQL against the same data in each test

Workload

Capture Replay

Production Test
database database

14 - 26 Copyright © 2009, Oracle. All rights reserved.


The Big Picture
Prechange production system Postchange test system

Clients/App servers
Capture directory Replay
system

Process capture files


Shadow capture file

Shadow capture file

Shadow capture file


Test
Production Shadow capture file system
system with
changes

Production Database Database


database backup restore
Can use Snapshot Standby as test system

14 - 27 Copyright © 2009, Oracle. All rights reserved.


Quiz

Select the statements that are true about statistics collection:


1. You can manually collect statistics with the DBMS_STATS
package.
2. You can automatically collect statistics by enabling
Automatic Maintenance Tasks.
3. You can import statistics from another database.
4. You can collect statistics by setting database initialization
parameters.
5. You can collect statistics by manually updating the data
dictionary.

14 - 28 Copyright © 2009, Oracle. All rights reserved.


Summary

In this lesson, you should have learned how to:


• Monitor the performance of sessions and services
• Describe the benefits of Database Replay

14 - 29 Copyright © 2009, Oracle. All rights reserved.


Practice 14 Overview:
Monitoring Instance Performance
This practice covers the following topics:
• Monitoring Top Services and Sessions

14 - 30 Copyright © 2009, Oracle. All rights reserved.

S-ar putea să vă placă și