0% found this document useful (0 votes)
20 views43 pages

Les 15 Perf

This document outlines the objectives and methodologies for managing database performance, including monitoring sessions, utilizing the SQL Tuning Advisor, and the SQL Access Advisor for workload tuning. It emphasizes the importance of performance planning, instance tuning, and SQL tuning, along with the collection of accurate statistics for effective SQL performance tuning. Additionally, it introduces Database Replay as a means to capture and test production workloads realistically.

Uploaded by

nguyen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views43 pages

Les 15 Perf

This document outlines the objectives and methodologies for managing database performance, including monitoring sessions, utilizing the SQL Tuning Advisor, and the SQL Access Advisor for workload tuning. It emphasizes the importance of performance planning, instance tuning, and SQL tuning, along with the collection of accurate statistics for effective SQL performance tuning. Additionally, it introduces Database Replay as a means to capture and test production workloads realistically.

Uploaded by

nguyen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 43

15

Managing Database Performance

Copyright © 2007, Oracle. All rights reserved.


Objectives

After completing this lesson, you should be able to:


• Monitor the performance of sessions and services
• Use the SQL Tuning Advisor to:
– Identify SQL statements that are using the most resources
– Tune SQL statements that are using the most resources
• Use the SQL Access Advisor to tune a workload
• Describe the benefits of Database Replay

15 - 2 Copyright © 2007, Oracle. All rights reserved.


Tuning Activities

The three activities in performance management are:


• Performance planning
• Instance tuning
• SQL tuning

15 - 3 Copyright © 2007, Oracle. All rights reserved.


Performance Planning

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

15 - 4 Copyright © 2007, 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.

15 - 6 Copyright © 2007, 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.

15 - 7 Copyright © 2007, Oracle. All rights reserved.


Performance Monitoring

Enterprise Manager provides:


• Performance overview on the database home page

• Graphs of metrics and details through the Performance tab

15 - 8 Copyright © 2007, 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

15 - 9 Copyright © 2007, Oracle. All rights reserved.


Optimizer Statistics Collection

• SQL performance tuning depends on the collection of


accurate statistics.
• There are different types of statistics:
– Optimizer statistics
– System statistics
• There are different methods of collecting statistics:
– Automatically, through the Automatic Maintenance Tasks
– Manually, with the DBMS_STATS package
– By setting database initialization parameters
– By importing statistics from another database

15 - 10 Copyright © 2007, 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.

15 - 12 Copyright © 2007, Oracle. All rights reserved.


System 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
• event_number V$SYSTEM_EVENT
• event
• event_id
• total_waits
• name
• total_timeouts
• parameter1
• time_waited
• parameter2
• average_wait
• parameter3
• time_waited_micro
• wait_class

15 - 13 Copyright © 2007, Oracle. All rights reserved.


Monitoring Session Performance

Details of session performance are available in EM:

15 - 15 Copyright © 2007, 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

15 - 16 Copyright © 2007, 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

15 - 17 Copyright © 2007, 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

15 - 18 Copyright © 2007, Oracle. All rights reserved.


Dictionary Views

• The following dictionary and special views provide useful


statistics after using 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.

15 - 19 Copyright © 2007, 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

15 - 20 Copyright © 2007, Oracle. All rights reserved.


SQL Tuning

SQL tuning process


• Identify poorly tuned SQL statements.
• Tune the individual statements.
• Tune the application as a whole.

15 - 22 Copyright © 2007, Oracle. All rights reserved.


SQL Advisors

15 - 23 Copyright © 2007, Oracle. All rights reserved.


Automatic SQL Tuning Results

15 - 24 Copyright © 2007, Oracle. All rights reserved.


Implement Automatic Tuning
Recommendations

15 - 25 Copyright © 2007, Oracle. All rights reserved.


SQL Tuning Advisor: Overview

Comprehensive SQL tuning

Detect stale or missing


statistics

Tune SQL plan


(SQL profile)

Add missing index

SQL Tuning
Add materialized view
Advisor
Restructure SQL

Implement partitioning

15 - 26 Copyright © 2007, Oracle. All rights reserved.


Using the SQL Tuning Advisor

• Use the SQL Tuning Advisor to analyze SQL statements and


obtain performance recommendations.
• Sources for SQL Tuning Advisor to analyze:
– Top Activity: Analyzes the top SQL statements currently
active
– SQL Tuning Sets: Analyzes a set of SQL statements you
provide
– Historical SQL (AWR): Analyzes SQL statements from
statements collected by AWR snapshots

15 - 27 Copyright © 2007, Oracle. All rights reserved.


SQL Tuning Advisor Options

15 - 28 Copyright © 2007, Oracle. All rights reserved.


SQL Tuning Advisor
Recommendations

15 - 29 Copyright © 2007, Oracle. All rights reserved.


Using the SQL Tuning Advisor: Example

15 - 30 Copyright © 2007, Oracle. All rights reserved.


SQL Tuning Advisor:
Identifying Duplicate SQL

Bind variable
candidates

15 - 31 Copyright © 2007, Oracle. All rights reserved.


SQL Access Advisor: Overview

Workload specification
Recommendations
-SQL statement
-Indexes
-SQL Tuning Set
-Materialized views
-SQL cache contents
-Materialized view logs
-Statistics
-Partitioning
-Schema name

SQL Access
Advisor

15 - 32 Copyright © 2007, Oracle. All rights reserved.


Typical SQL Access Advisor Session

15 - 33 Copyright © 2007, Oracle. All rights reserved.


Workload Source

15 - 34 Copyright © 2007, Oracle. All rights reserved.


Recommendation Options

15 - 35 Copyright © 2007, Oracle. All rights reserved.


Recommendation Options

15 - 36 Copyright © 2007, Oracle. All rights reserved.


Reviewing Recommendations

15 - 37 Copyright © 2007, Oracle. All rights reserved.


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

15 - 38 Copyright © 2007, Oracle. All rights reserved.


System Architecture: Capture

Capture directory

Shadow capture file


Shadow Shadow Shadow Shadow

Shadow capture file


Recording infrastructure
Database stack Shadow capture file

Shadow capture file


Background Background

Database
backup

Production
database

15 - 39 Copyright © 2007, Oracle. All rights reserved.


System Architecture: Processing the Workload

Capture directory

Process capture files


Shadow capture file

Shadow capture file

Database stack Shadow capture file

Shadow capture file


Background Background

Database
backup

Production
Process
database capture

15 - 40 Copyright © 2007, Oracle. All rights reserved.


System Architecture: Replay
Replay
system Replay Replay
client client
Capture directory

Process capture files


Shadow … Shadow Shadow … Shadow
Shadow capture file

Shadow capture file

Database stack Shadow capture file

Shadow capture file


Background Background

Test
system
with
Database changes

backup

Test
database

15 - 41 Copyright © 2007, 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

15 - 42 Copyright © 2007, Oracle. All rights reserved.


Workloads Supported

• Captured operations:
– All SQL (DML, DDL, PL/SQL) with practically all types of binds
– Full LOB functionality (cursor based and direct OCI)
– Local transactions
– Login/logoff
– Session switching
– Limited PL/SQL RPCs
• Limitations: Operations not captured
– Direct path load, import/export
– OCI-based object navigation (ADTs) and REF binds
– Streams, non-PL/SQL-based AQ
– Distributed transactions, remote describe/commit operations
– Flashback (Database and Query)
– Shared server

15 - 43 Copyright © 2007, Oracle. All rights reserved.


Using Enterprise Manager for Workload Capture

Start

Workload recording

Plan

Shutdown - Startup Restricted


...

Capture Raw captured


data

15 - 44 Copyright © 2007, Oracle. All rights reserved.


Using Enterprise Manager for Workload Replay

Workload Replay

Process Capture
Replay Files
& Metadata
Raw captured data
(from production Initialize Replay
system)
Prepare

Replay
Replay
Report
Analyze End

15 - 45 Copyright © 2007, Oracle. All rights reserved.


Summary

In this lesson, you should have learned how to:


• Monitor the performance of sessions and services
• Use the SQL Tuning Advisor to:
– Identify SQL statements that are using the most resources
– Tune SQL statements that are using the most resources
• Use the SQL Access Advisor to tune a workload
• Describe the benefits of Database Replay

15 - 46 Copyright © 2007, Oracle. All rights reserved.


Practice 15 Overview:
Monitor Instance Performance
This practice covers the following topics:
• Monitoring Top Services and Sessions
• Using SQL Tuning Advisor
• Using SQL Access Advisor

15 - 47 Copyright © 2007, Oracle. All rights reserved.

You might also like