Perfomance Tuning
Perfomance Tuning
Sean Kim This document contains proprietary information and is protected by copyright and other
Darryl Balaski intellectual property laws. The document may not be modified or altered in any way.
Except where your use constitutes "fair use" under copyright law, you may not use, share,
download, upload, copy, print, display, perform, reproduce, publish, license, post,
Technical Contributors transmit, or distribute this document in whole or in part without the express authorization
of Oracle.
and Reviewers
The information contained in this document is subject to change without notice and is not
Mark Fuller warranted to be error-free. If you find any errors, please report them to us in writing.
James Spiller
Restricted Rights Notice
Jim Womack
If this documentation is delivered to the United States Government or anyone using the
documentation on behalf of the United States Government, the following notice is
Publishers applicable:
Sujatha Nagendra
U.S. GOVERNMENT END USERS: Oracle programs (including any operating system,
Pavithran Adka integrated software, any programs embedded, installed or activated on delivered
hardware, and modifications of such programs) and Oracle computer documentation or
Giri Venugopal
other Oracle data delivered to or accessed by U.S. Government end users are "commercial
computer software" or "commercial computer software documentation" pursuant to the
applicable Federal Acquisition Regulation and agency-specific supplemental regulations.
As such, the use, reproduction, duplication, release, display, disclosure, modification,
2010032022 preparation of derivative works, and/or adaptation of i) Oracle programs (including any
operating system, integrated software, any programs embedded, installed or activated on
delivered hardware, and modifications of such programs), ii) Oracle computer
documentation and/or iii) other Oracle data, is subject to the rights and limitations
specified in the license contained in the applicable contract. The terms governing the U.S.
Government's use of Oracle cloud services are defined by the applicable contract for such
services. No other rights are granted to the U.S. Government.
Trademark Notice
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners.
Intel and Intel Inside are trademarks or registered trademarks of Intel Corporation. All
SPARC trademarks are used under license and are trademarks or registered trademarks of
SPARC International, Inc. AMD, Epyc, and the AMD logo are trademarks or registered
trademarks of Advanced Micro Devices. UNIX is a registered trademark of The Open
Group.
This documentation may provide access to or information about content, products, and
services from third parties. Oracle Corporation and its affiliates are not responsible for and
expressly disclaim all warranties of any kind with respect to third-party content, products,
and services unless otherwise set forth in an applicable agreement between you and
Oracle. Oracle Corporation and its affiliates will not be responsible for any loss, costs, or
damages incurred due to your access to or use of third-party content, products, or
services, except as set forth in an applicable agreement between you and Oracle.
Contents
1 Overview
Objectives 1-2
What Is Performance Management? 1-3
Who Manages Performance? 1-4
What Does the DBA Tune? 1-5
Types of Tuning 1-6
Tuning Methodology 1-7
Effective Tuning Goals 1-9
General Tuning Session 1-11
Tuning a CDB 1-13
Performance Tuning: Diagnostics 1-14
Performance Tuning: Features and Tools 1-15
Tuning Objectives 1-16
Summary 1-17
Practice Overview 1-18
iii
3 Using the Time Model to Diagnose Performance Issues
Objectives 3-2
Time Model: Overview 3-3
DB Time 3-4
CPU and Wait Time Tuning Dimensions 3-5
Time Model Statistics Hierarchy 3-6
Time Model: Example 3-8
Top Timed Events 3-9
Summary 3-10
Practice Overview 3-11
iv
6 Using Enterprise Manager Cloud Control and SQL Developer to Monitor
Performance
Objectives 6-2
Enterprise Manager: Overview 6-3
Configuring Enterprise Manager Database Express 6-4
Oracle Enterprise Manager Cloud Control Components 6-5
Using Features of the Oracle Management Packs and Options 6-6
Oracle SQL Developer 6-7
SQL Developer Command Line (SQLcl) 6-8
Summary 6-9
Practice Overview 6-10
v
AWR Snapshot Purging Policy 8-7
Managing Snapshots with PL/SQL 8-8
AWR Snapshot Settings 8-9
Manual AWR Snapshots 8-10
Managing AWR Data in a Multitenant Environment 8-11
AWR Snapshots and ADDM in a Multitenant Architecture Database 8-12
Generating AWR Reports 8-13
Reading the AWR Report 8-14
AWR Report: Multitenant Data 8-15
Generating AWR Reports by Using SQL*Plus 8-16
Statspack and AWR Reports 8-17
Reading a Statspack or an AWR Report 8-18
Compare Periods: Benefits 8-19
Snapshots and Periods Comparisons 8-20
Compare Periods: Results 8-21
Compare Periods: Report 8-22
Multitenant AWR Views 8-23
Summary 8-24
Practice Overview 8-25
10 Using Baselines
Objectives 10-2
Comparative Performance Analysis with AWR Baselines 10-3
Automatic Workload Repository Baselines 10-4
vi
AWR Baselines 10-5
Types of Baselines 10-6
Moving Window Baseline 10-7
Baselines in Performance Page Settings 10-8
Baseline Templates 10-9
Creating AWR Baselines 10-10
Creating a Single AWR Baseline 10-11
Creating a Repeating Baseline and Template 10-12
Managing Baselines by Using the DBMS_WORKLOAD_REPOSITORY
Package 10-13
Generating a Baseline Template for a Single Time Period 10-14
Creating a Repeating Baseline Template 10-15
Baseline Views 10-16
Performance Monitoring and Baselines 10-17
Defining Alert Thresholds by Using a Static Baseline 10-19
Configuring a Basic Set of Thresholds 10-20
Summary 10-21
Practice 3 Overview: Using AWR Baselines 10-22
vii
Workload Compatibility 12-14
Configuring Automatic ADDM Analysis at the PDB Level 12-15
Using the DBMS_ADDM Package to Compare Periods 12-16
Example: Using the DBMS_ADDM Package to Compare Periods 12-17
Summary 12-18
Practice Overview 12-19
13 Using Active Session History Data for First Fault System Analysis
Objectives 13-2
Active Session History: Overview 13-3
Active Session History: Mechanics 13-4
ASH Sampling: Example 13-5
Accessing ASH Data 13-6
Analyzing the ASH Data 13-7
Using Enterprise Manager to Generate ASH Reports 13-8
Using the ASH Report Script to Generate a Report 13-9
ASH Report Structure 13-10
Determining the Source of Data 13-11
Performing Skew Analysis 13-12
Additional Automatic Workload Repository Views 13-13
Summary 13-14
Practice Overview 13-15
viii
Cursor Usage and Parsing 15-7
SQL Statement Processing Phases: Bind 15-8
SQL Statement Processing Phases: Execute and Fetch 15-9
Processing a DML Statement 15-10
Commit Processing 15-12
Identifying Poorly Performing SQL Statements 15-13
Top SQL Reports 15-14
SQL Monitoring 15-15
Monitored SQL Execution Details 15-16
Summary 15-17
16 Maintaining Indexes
Objectives 16-2
Creating Indexes 16-3
Using Invisible and Unusable Indexes 16-4
Dropping Indexes 16-5
Reducing the Cost of SQL Operations 16-6
Index Maintenance 16-7
Using Advanced Index Compression 16-9
Other Index Options 16-10
SQL Access Advisor 16-11
Quiz 16-12
Automatic Indexing Task 16-13
Automatic Index Task Workflow 16-15
Automatic Indexing Task Reporting 16-16
Automatic Indexing Views 16-17
Summary 16-18
Practice Overview 16-19
17 Maintaining Tables
Objectives 17-2
Reducing the Cost of SQL Operations 17-3
Table Maintenance for Performance 17-4
Table Reorganization Methods 17-5
Space Management 17-6
Extent Management 17-7
Locally Managed Extents 17-8
Large Extents: Considerations 17-9
How Table Data Is Stored 17-11
Anatomy of a Database Block 17-12
Minimize Block Visits 17-13
ix
Block Allocation 17-14
Free Lists 17-15
Block Space Management 17-16
Block Space Management with Free Lists 17-17
Automatic Segment Space Management 17-19
Automatic Segment Space Management at Work 17-20
Block Space Management with ASSM 17-21
Creating an Automatic Segment Space Management Segment 17-22
Migration and Chaining 17-23
Guidelines for PCTFREE and PCTUSED 17-25
Detecting Migration and Chaining 17-26
Selecting Migrated Rows 17-27
Eliminating Migrated Rows 17-28
Shrinking Segments: Overview 17-30
Shrinking Segments: Considerations 17-31
Shrinking Segments by Using SQL 17-32
Segment Shrink: Basic Execution 17-33
Segment Shrink: Execution Considerations 17-34
Data Compression 17-35
Advanced Row Compression: Overview 17-37
Advanced Row Compression: Concepts 17-38
Using Advanced Row Compression 17-39
Advanced Row Compression for DML Operations 17-40
Advanced Index Compression 17-41
How Does Hybrid Columnar Compression Work? 17-42
Using the Compression Advisor 17-43
Using the Compression Advisor for Indexes 17-44
Viewing Table Compression Information 17-45
Quiz 17-46
Summary 17-47
Practice Overview 17-48
x
Enabling Query Optimizer Features 18-13
Influencing the Optimizer Approach 18-14
Optimizing SQL Statements 18-15
Access Paths 18-16
Choosing an Access Path 18-17
Summary 18-18
xi
Disabling SQL Trace 20-9
Formatting Your Trace Files 20-10
TKPROF Command Options 20-11
Output of the TKPROF Command 20-13
TKPROF Output with No Index: Example 20-18
TKPROF Output with Index: Example 20-19
Generating an Optimizer Trace 20-20
Summary 20-21
Practice Overview 20-22
xii
23 Using the SQL Plan Management Feature
Objectives 23-2
SQL Plan Management: Overview 23-3
SQL Plan Baseline: Architecture 23-4
Loading SQL Plan Baselines 23-5
Loading SQL Plan Baselines from AWR 23-6
Evolving SQL Plan Baselines 23-7
Adaptive SQL Plan Management 23-8
Automatically Evolving SQL Plan Baseline 23-9
Including Alternate Plans in the SPM Evolve Advisor List 23-10
Important Baseline SQL Plan Attributes 23-11
SQL Plan Selection 23-12
Possible SQL Plan Manageability Scenarios 23-13
SQL Performance Analyzer and SQL Plan Baseline Scenario 23-14
Loading a SQL Plan Baseline Automatically 23-15
Purging SQL Management Base Policy 23-16
Enterprise Manager and SQL Plan Baselines 23-17
Quiz 23-18
Summary 23-19
Practice Overview 23-20
xiii
26 Using the SQL Access Advisor
Objectives 26-2
SQL Access Advisor: Overview 26-3
Using the SQL Access Advisor 26-4
Viewing Recommendations 26-5
Viewing Recommendation Details 26-6
Summary 26-7
Practice Overview 26-8
xiv
Replay Considerations 29-14
Replay Customized Options 29-15
Replay Analysis 29-16
Quiz 29-17
Database Replay Packages 29-18
Data Dictionary Views: Database Replay 29-19
Database Replay: PL/SQL Example 29-20
Calibrating Replay Clients 29-22
Capturing and Replaying in a CDB and PDBs 29-23
Reporting 29-24
Quiz 29-25
Summary 29-26
Practice Overview 29-27
xv
Using the DBMS_SERVICE Package to Manage Services 31-7
Where are services used? 31-8
Using Services with Client Applications 31-9
Using Services with the Resource Manager 31-10
Using Enterprise Manager to Manage Consumer Group Mappings 31-11
Services and the Resource Manager: Example 31-12
Using Enterprise Manager to Create a Job Class 31-13
Using Enterprise Manager to Create a Job 31-14
Services and the Scheduler: Example 31-15
Using Services with Metric Thresholds 31-16
Using Enterprise Manager to Change Service Thresholds 31-17
Services and Metric Thresholds: Example 31-18
Service Aggregation and Tracing 31-19
Top Services Performance Page 31-20
Service Aggregation Configuration 31-21
Service Aggregation: Example 31-22
Client Identifier Aggregation and Tracing 31-23
Using the TRCSESS Utility 31-24
Service Performance Views 31-25
Summary 31-27
Practice Overview 31-28
xvi
Instance Efficiencies 33-15
Library Cache Activity 33-16
Avoid Hard Parses 33-17
Are Cursors Being Shared? 33-18
Candidate Cursors for Sharing 33-19
Sharing Cursors 33-20
Adaptive Cursor Sharing: Example 33-21
Adaptive Cursor Sharing Views 33-23
Interacting with Adaptive Cursor Sharing 33-24
Reduce the Cost of Soft Parses 33-25
Quiz 33-26
Sizing the Shared Pool 33-27
Shared Pool Advisory 33-28
Shared Pool Advisory in an AWR Report 33-29
Shared Pool Advisor 33-30
Avoiding Fragmentation 33-31
Large Memory Requirements 33-32
Tuning the Shared Pool Reserved Pool 33-34
Keeping Large Objects 33-36
Data Dictionary Cache 33-38
Dictionary Cache Misses 33-39
SQL Query Result Cache: Overview 33-40
Managing the SQL Query Result Cache 33-41
Using the RESULT_CACHE Hint 33-43
Using Table Annotation to Control Result Caching 33-44
Using the DBMS_RESULT_CACHE Package 33-45
Viewing SQL Result Cache Dictionary Information 33-46
SQL Query Result Cache: Considerations 33-47
Summary 33-48
Practice Overview 33-49
xvii
Finding Hot Segments 34-12
Buffer Busy Waits 34-13
Buffer Cache Hit Ratio 34-14
Buffer Cache Hit Ratio is Not Everything 34-15
Interpreting Buffer Cache Hit Ratio 34-16
Read Waits 34-17
Free Buffer Waits 34-18
Solutions for Buffer Cache Issues 34-19
Sizing the Buffer Cache 34-20
Buffer Cache Size Parameters 34-21
Dynamic Buffer Cache Advisory Parameter 34-22
Buffer Cache Advisory View 34-23
Using the V$DB_CACHE_ADVICE View 34-24
Using the Buffer Cache Advisor 34-25
Caching Tables 34-26
Automatic Big Table Caching 34-27
Configuring Automatic Big Table Caching 34-28
Using Automatic Big Table Caching 34-29
Monitoring Automatic Big Table Caching 34-30
Memoptimized Rowstore 34-31
In-Memory Hash Index 34-32
Multiple Buffer Pools 34-33
Enabling Multiple Buffer Pools 34-34
Calculating the Hit Ratio for Multiple Pools 34-35
Multiple Block Sizes 34-36
Multiple Database Writers 34-37
Multiple I/O Slaves 34-38
Using Multiple Writers and I/O Slaves 34-39
Private Pool for I/O-Intensive Operations 34-40
Automatically Tuned Multiblock Reads 34-41
Database Smart Flash Cache Overview 34-42
Using Database Smart Flash Cache 34-43
Database Smart Flash Cache Architecture Overview 34-44
Configuring Database Smart Flash Cache 34-45
Sizing Database Smart Flash Cache 34-46
Enabling and Disabling Flash Devices 34-47
Specifying Database Smart Flash Cache for a Table 34-48
Full Database In-Memory Caching 34-49
Setting Up Force Full Database Caching 34-50
Monitoring Full Database In-Memory Caching 34-51
Flushing the Buffer Cache (for Testing Only) 34-52
xviii
Summary 34-53
Practice Overview 34-54
xix
37 Using Automatic Shared Memory Management
Objectives 37-2
Oracle Database Architecture 37-3
Granules 37-4
Automatic Shared Memory Management: Overview 37-5
SGA Sizing Parameters: Overview 37-6
Dynamic SGA Transfer Modes 37-7
Memory Broker Architecture 37-8
Manually Resizing Dynamic SGA Parameters 37-9
Behavior of Auto-Tuned SGA Parameters 37-10
Behavior of Manually Tuned SGA Components 37-11
Using the V$SYSTEM_PARAMETER View 37-12
Resizing SGA_TARGET 37-13
Disabling Automatic Shared Memory Management 37-14
Using the SGA Advisor 37-15
Monitoring ASMM 37-16
Managing SGA for PDBs 37-17
Summary 37-18
Practice Overview 37-19
xx
In-Memory Advisor 39-7
IM Advisor or Compression Advisor? 39-8
Computing Compression Ratio 39-9
IM FastStart 39-10
Automatic In-Memory: Overview 39-11
AIM Action 39-12
Configuring Automatic In-Memory 39-13
Diagnostic Views 39-14
Summary 39-15
Practice Overview 39-16
xxi
Managing Heat Map and Automatic Data Optimization Policies 41-10
Creating ADO In-Memory Policies 41-12
Summary 41-13
Practice Overview 41-14
xxii