You are on page 1of 14

Oracle Database 10g: Performance Tuning

Volume I Student Guide

D19165GC10 Edition 1.0 February 2006 D44732

Authors
James Spiller Jean-Francois Verrier

Copyright 2006, Oracle. All rights reserved. Disclaimer This document contains proprietary information and is protected by copyright and other intellectual property laws. You may copy and print this document solely for your own use in an Oracle training course. 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, transmit, or distribute this document in whole or in part without the express authorization of Oracle. The information contained in this document is subject to change without notice. If you find any problems in the document, please report them in writing to: Oracle University, 500 Oracle Parkway, Redwood Shores, California 94065 USA. This document is not warranted to be error-free. Restricted Rights Notice 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 applicable: U.S. GOVERNMENT RIGHTS The U.S. Governments rights to use, modify, reproduce, release, perform, display, or disclose these training materials are restricted by the terms of the applicable Oracle license agreement and/or the applicable U.S. Government contract. Trademark Notice Oracle, JD Edwards, PeopleSoft, and Siebel are registered trademarks of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.

Technical Contributors and Reviewers


Mirza Ahmad Christian Bauwens Tom Best Maria Billings Harald Van Breederode Mary Bryksa Peter Caldwell Immanuel Chan Edward Choi Patrick Cullen Andy Fortunak Joel Goodman Bert Van Gorkom Scott Gossett Connie Green Laurie Holdren Sanjeev Joglekar Pete Jones Donna Keesling Teria Kidd Vishal Kohli Subodh Kumar Pierre Labrousse Herve Lejuene Stefan Lindblad Roderick Manalac Louise Morin Howard Ostrow Jagadeesh Papajah Gopi Ramamoorthy Joerg Reinschmidt Rick Shavwer Ira Singer Janet Stern Bransislav Valny Christian Weinfurtner Lester Wells James Womack Anthony Woodell Fang Wu

Editors
Atanu Raychaudhuri Nita Pavitran

Graphic Designer
James Hans

Publisher
Giri Venugopal

Contents
Preface 1 Introduction Course Objectives 1-2 Agenda 1-3 Tuning Questions 1-5 Who Tunes? 1-6 What to Tune Overall? 1-7 What to Tune in the Instance 1-9 How to Tune 1-10 Traditional Performance Tuning Methodology Challenges 1-11 Performance Monitoring Solutions 1-12 Using Features of the Packs 1-14 Tuning Scenario Alternatives 1-16 Tuning Methodology 1-18 Summary 1-20 Performance Tuning: Overview Objectives 2-2 General Tuning Session 2-3 Defining the Problem 2-5 Setting the Priority 2-6 Tuning Methodology: Setting the Priority Example 2-7 Common Tuning Problems 2-8 ADDM Tuning Session 2-9 Effective Tuning Goals 2-10 Tuning Objectives 2-12 DB Time 2-13 CPU and Wait Time Tuning Dimensions 2-14 Tuning Life Cycle Phases 2-15 Tuning Steps During Life Cycle 2-16 Application Design and Development 2-17 Testing: Database Configuration 2-18 Deployment 2-19 Production 2-20 Collecting a Baseline Set of Statistics 2-21 Performance Versus Safety Trade-Offs 2-22 Filing a Performance Service Request 2-23 RDA Report 2-24 Monitoring and Tuning Tool: Overview 2-25 Practice Overview: Write Tuning Goals 2-27 Summary 2-28

iii

Statistics and Wait Events Objectives 3-2 Performance Tuning Data 3-3 Performance Tuning Tools 3-4 Accessing the Database Home Page 3-5 EM Performance Pages 3-6 Viewing the Alert Log 3-8 Using Alert Log Information to Aid in Tuning 3-9 User Trace Files 3-11 Background Process Trace Files 3-12 Dynamic Performance Views 3-13 Dynamic Performance Views: Usage Examples 3-14 Dynamic Performance Views: Considerations 3-15 Statistic Levels 3-16 Statistics and Wait Events 3-18 System Statistic Classes 3-19 Displaying Systemwide Statistics 3-20 Displaying Session-Related Statistics 3-22 Displaying Service-Related Statistics 3-24 Wait Events 3-26 Commonly Observed Wait Events 3-27 Wait Classes 3-28 Using the V$EVENT_NAME View 3-30 Wait Event Statistics 3-31 Using the V$SESSION_EVENT View 3-32 Using the V$SESSION_WAIT View 3-33 Using the V$SYSTEM_EVENT View 3-35 Precision of System Statistics 3-36 Time Model: Overview 3-37 Time Model Statistics Hierarchy 3-38 Practice Overview: Use Basic Tools 3-40 Summary 3-41 Metrics, Alerts, and Baselines Objectives 4-2 Metrics, Alerts, and Baselines 4-3 Limitation of Base Statistics 4-4 Typical Delta Tools 4-5 Oracle Database 10g Solution: Metrics 4-6 Benefits of Metrics 4-7 Viewing Metric History Information 4-8 Viewing Detailed Information for a Metric 4-9

iv

Statistic Histograms 4-10 Histogram Views 4-11 Server-Generated Alerts 4-12 Database Control Usage Model 4-13 Setting Thresholds 4-14 Creating and Testing an Alert 4-15 Metric and Alert Views 4-16 User-Defined SQL Metrics 4-17 Practice Overview: Work with Metrics 4-18 Working with Metric Baselines 4-19 Enabling Metric Baselining 4-20 Creating Static Metric Baselines 4-21 Time Grouping 4-23 Time Grouping: Considerations 4-24 Activating the Static Metric Baseline 4-25 Activating the Moving Window Metric Baseline 4-26 Visualizing Metric Baseline Statistics 4-27 Setting Adaptive Alert Thresholds 4-28 Metric Baseline and Adaptive Threshold: Considerations 4-30 Classification of Eligible Metrics 4-31 Metric Baseline: Normalized View 4-32 Configuring Normalization Metrics 4-33 Adaptive Thresholds and the All Metrics Page 4-34 Practice Overview: Work with Baselines 4-35 Summary 4-36 5 Using Statspack Objectives 5-2 Introduction to Statspack 5-3 Statspack Scripts 5-4 Installing Statspack 5-6 Capturing Statspack Snapshots 5-7 Configuring Snapshot Data Capture 5-8 Statspack Snapshot Levels 5-9 Statspack Baselines and Purging 5-11 Reporting with Statspack 5-13 Statspack Considerations 5-14 Statspack and AWR Reports 5-16 Reading a Statspack or AWR Report 5-17 Statspack/AWR Report Drilldown Sections 5-18 Report Drilldown Examples 5-20 Load Profile Section 5-21 Time Model Section 5-22 Statspack and AWR 5-23

Practice Overview: Use Statspack 5-24 Summary 5-25 6 Using Automatic Workload Repository Objectives 6-2 Automatic Workload Repository: Overview 6-3 Automatic Workload Repository Data 6-4 Workload Repository 6-5 AWR Snapshot Sets 6-6 AWR Snapshot Purging Policy 6-7 AWR Snapshot Settings 6-8 Database Control and AWR 6-9 Generating AWR Reports in EM 6-10 Generating AWR Reports in SQL*Plus 6-11 Snapshot Sets and Period Comparisons 6-12 Compare Periods: Benefits 6-13 Compare Periods: General 6-14 Compare Periods: Report 6-15 AWR Data 6-16 DBMS_WORKLOAD_REPOSITORY Package 6-17 ADDM Performance Monitoring 6-18 ADDM and Database Time 6-19 DBTime-graph and ADDM Methodology 6-20 Top Performance Issues Detected 6-22 Database Control and ADDM Findings 6-23 ADDM Analysis Results 6-24 ADDM Recommendations 6-25 Database Control and ADDM Task 6-26 Changing ADDM Attributes 6-27 Retrieving ADDM Reports by Using SQL 6-28 Active Session History: Overview 6-29 Active Session History: Mechanics 6-30 ASH Sampling: Example 6-31 Accessing ASH Data 6-32 Dump ASH to File 6-33 Sifting the ASHes 6-34 Generating ASH Reports 6-35 ASH Report Script 6-36 ASH Report: General Section 6-37 ASH Report Structure 6-38 ASH Report: Activity Over Time 6-39 Practice Overview: Use AWR-Based Tools 6-40 Summary 6-41

vi

Reactive Tuning Objectives 7-2 Where Is the Problem? 7-3 OS Issues 7-4 Database Home Page 7-6 OS Statistics and Enterprise Manager 7-7 OS Statistics 7-8 Application Issues 7-9 Instance Issues 7-11 Architecture 7-12 Performance Management Approach 7-13 Performance Pages For Reactive Tuning 7-14 Database Home Page 7-15 Database Performance Page 7-16 Active Sessions Waiting Pages 7-18 SQL Details 7-20 Historical Data View 7-21 Diagnosis of Hung or Extremely Slow Databases 7-22 Using Memory Access Mode 7-23 Using the Hang Analysis Page 7-24 Practice Overview: Reactive Tuning 7-26 Summary 7-27 Tuning the Shared Pool Objectives 8-2 Shared Pool Architecture 8-3 Shared Pool Operation 8-4 The Library Cache 8-5 SQL and PL/SQL Storage 8-6 Cursor Usage and Parsing 8-7 Important Shared Pool Latches 8-9 Mutex 8-10 Benefits of Mutex 8-11 Mutex Views and Statistics 8-13 Mutex-Protected Operations 8-15 Statspack/AWR Indicators 8-16 Load Profile 8-17 Instance Efficiencies 8-18 Top Waits 8-19 Time Model 8-20 Library Cache Activity 8-22 Terminology 8-23 Diagnostic Tools for Tuning the Shared Pool 8-24 Library Cache Reloads 8-26

vii

Invalidations 8-27 Avoid Hard Parses 8-29 Are Cursors Being Shared? 8-30 Sharing Cursors 8-32 Avoiding Soft Parses 8-33 Avoiding Fragmentation 8-34 Sizing the Shared Pool 8-35 Shared Pool Advisory 8-36 Shared Pool Advisor 8-38 Large Memory Requirements 8-39 Tuning the Shared Pool Reserved Space 8-41 Keeping Large Objects 8-43 Data Dictionary Cache 8-45 Dictionary Cache Misses 8-46 UGA and Oracle Shared Server 8-47 Large Pool 8-48 Tuning the Large Pool 8-49 Practice Overview: Tune the Shared Pool 8-50 Summary 8-51 9 Tuning the Buffer Cache Objectives 9-2 Oracle Database Architecture 9-3 Buffer Cache: Highlights 9-4 Database Buffers 9-5 Buffer Hash Table For Lookups 9-6 Working Sets 9-7 Tuning Goals and Techniques 9-9 Symptoms 9-11 Cache Buffer Chains Latch Contention 9-12 Finding Hot Segments 9-13 Buffer Busy Waits 9-14 Calculating the Buffer Cache Hit Ratio 9-15 Buffer Cache Hit Ratio Is Not Everything 9-16 Interpreting Buffer Cache Hit Ratio 9-17 Read Waits 9-19 Free Buffer Waits 9-21 Solutions 9-22 Sizing the Buffer Cache 9-23 Buffer Cache Size Parameters 9-24 Dynamic Buffer Cache Advisory Parameter 9-25 View to Support Buffer Cache Advisory 9-26 Using the V$DB_CACHE_ADVICE View 9-27 Using the Buffer Cache Advisory with EM 9-28

viii

Caching Tables 9-29 Multiple Buffer Pools 9-30 Enabling Multiple Buffer Pools 9-32 Calculating the Hit Ratio for Multiple Pools 9-33 Multiple Block Sizes 9-35 Multiple Database Writers 9-36 Multiple I/O Slaves 9-37 Use Multiple Writers or IO Slaves 9-38 Private Pool for I/O Intensive Operations 9-39 Automatically Tuned Multiblock Reads 9-40 Faster Instance Startup for Ultralarge Buffer Caches 9-41 Flushing the Buffer Cache (for Testing Only) 9-42 Practice: Overview 9-43 Summary 9-44 10 Automatic Shared Memory Management Objectives 10-2 Oracle Database Architecture 10-3 Dynamic SGA Feature 10-4 Granule 10-5 Memory Advisories 10-6 Manually Adding Granules to Components 10-7 Increasing the Size of an SGA Component 10-8 Automatic Shared Memory Management: Overview 10-9 SGA Sizing Parameters: Overview 10-10 Benefits of Automatic Shared Memory Management 10-11 Dynamic SGA Transfer Modes 10-12 Memory Broker Architecture 10-13 Manually Resizing Dynamic SGA Parameters 10-14 Behavior of Auto-Tuned SGA Parameters 10-15 Behavior of Manually Tuned SGA Parameters 10-16 Using the V$PARAMETER View 10-17 Resizing SGA_TARGET 10-18 Disabling Automatic Shared Memory Management 10-19 Configuring ASMM 10-20 SGA Advisor 10-21 Monitoring ASMM 10-22 Practice: Overview 10-23 Summary 10-24 11 Checkpoint and Redo Tuning Objectives 11-2 Checkpoint and Redo 11-3 Oracle Database Architecture 11-4

ix

Checkpoint Architecture 11-5 Database Writer (DBWn) Process 11-6 Checkpoint (CKPT) Process 11-7 Redo Architecture 11-8 The Redo Log Buffer 11-9 Redo Log Files and LogWriter 11-10 Archiver (ARCn) 11-11 Incremental Checkpointing 11-12 Incremental Checkpoint and Log File Size 11-14 Adjusting the Checkpoint Rate 11-15 Redo Logfile Size Advisor 11-16 Impact of the Checkpoint Rate 11-17 Automatic Checkpoint Tuning 11-19 ADDM Report: Checkpoints 11-20 ADDM Report: Redo Logs 11-21 Statspack and AWR Reports 11-22 Check Parameters 11-24 Check the Redo Log Size 11-25 Redo Log Chain Tuning 11-26 Reducing Redo Operations 11-28 Increasing the Performance of Archiving 11-30 Diagnostic Tools 11-32 Redo Log Groups and Members 11-33 Online Redo Log File Configuration 11-34 Monitoring Online Redo Log File I/O 11-35 Sizing the Redo Log Buffer 11-36 Diagnosing Redo Log Buffer Inefficiency 11-37 Diagnosing Log Buffer Problems 11-38 Log Space Request Waits: Further Investigation 11-40 Practice Overview: Diagnose Checkpoints and Redo 11-42 Summary 11-43 12 Tuning I/O Objectives 12-2 I/O Architecture 12-3 File System Characteristics 12-4 Raw Partitions 12-5 I/O Modes 12-6 Bandwidth Versus Size 12-7 Stripe and Mirror Everything 12-8 Using RAID 12-9 RAID Cost Versus Benefits 12-10 Should I Use RAID 1 or RAID 5? 12-12 Diagnostics 12-13

Database I/O Tuning 12-14 What Is Automatic Storage Management? 12-15 ASM: Key Features and Benefits 12-16 How Many Disk Groups per Database 12-18 Database Storage Consolidation 12-19 Which RAID Configuration for Best Availability? 12-20 ASM Mirroring Guidelines 12-21 ASM Striping Granularity 12-22 What Type of Striping Works Best? 12-23 ASM Striping Only 12-24 Hardware RAID Striped LUNs 12-25 ASM Guidelines 12-26 ASM Instance Initialization Parameters 12-27 Dynamic Performance Views 12-28 Monitoring Long-Running Operations by Using V$ASM_OPERATION 12-30 ASM Instance Performance Diagnostics 12-31 ASM Performance Page 12-32 Database Instance Parameter Changes 12-33 ASM Disk Metadata Requirements 12-34 ASM Scalability 12-35 Practice Overview: Tune I/O: A Demonstration 12-36 Summary 12-37 13 Tuning PGA and Temporary Space Objectives 13-2 SQL Memory Usage 13-3 Performance Impact 13-4 Automatic PGA Memory 13-5 SQL Memory Manager 13-6 Configuring Automatic PGA Memory 13-8 Setting PGA_AGGREGATE_TARGET Initially 13-9 Monitoring SQL Memory Usage 13-10 Monitoring SQL Memory Usage: Examples 13-12 Tuning SQL Memory Usage 13-13 PGA Target Advice Statistics 13-14 PGA Target Advice Histograms 13-15 Automatic PGA and Enterprise Manager 13-16 Automatic PGA and AWR Reports 13-17 Temporary Tablespace Management: Overview 13-18 Temporary Tablespace: Best Practice 13-19 Configuring Temporary Tablespace 13-20 Temporary Tablespace Group: Overview 13-22 Temporary Tablespace Group: Benefits 13-23 Creating Temporary Tablespace Groups 13-24

xi

Maintaining Temporary Tablespace Groups 13-25 Data Dictionary Changes 13-26 Monitoring Temporary Tablespace 13-27 Practice Overview: Tune PGA Memory 13-28 Summary 13-29 14 Tuning Block Space Usage Objectives 14-2 Space Management 14-3 Extent Management 14-4 Locally Managed Extents 14-5 Pros and Cons of Large Extents 14-6 Migrating the SYSTEM Tablespace to a Locally Managed Tablespace 14-8 How Table Data Is Stored 14-10 Anatomy of a Database Block 14-11 Minimize Block Visits 14-12 The DB_BLOCK_SIZE Parameter 14-13 Small Block Size: Considerations 14-14 Large Block Size: Considerations 14-15 Block Allocation 14-16 Free Lists 14-17 Block Space Management 14-18 Block Space Management with Free Lists 14-19 Automatic Segment Space Management 14-21 Automatic Segment Space Management at Work 14-22 Block Space Management with ASSM 14-24 Creating an Automatic Segment Space Management Segment 14-25 Migration and Chaining 14-26 Guidelines for PCTFREE and PCTUSED 14-28 Detecting Migration and Chaining 14-29 Selecting Migrated Rows 14-30 Eliminating Migrated Rows 14-31 Shrinking Segments: Overview 14-33 Shrinking Segments: Considerations 14-34 Shrinking Segments by Using SQL 14-35 Segment Shrink: Basic Execution 14-36 Segment Shrink: Execution Considerations 14-37 Using EM to Shrink Segments 14-38 Bigfile Tablespaces: Overview 14-39 Bigfile Tablespaces: Benefits 14-41 Using Bigfile Tablespaces 14-43 Practice Overview: Tune Database Space Usage 14-44 Summary 14-45

xii

15 Performance Tuning: Summary Objectives 15-2 Necessary Initialization Parameters with Little Performance Impact 15-3 Important Initialization Parameters with Performance Impact 15-4 Sizing Memory Initially 15-6 Database High Availability: Best Practices 15-7 Undo Tablespace: Best Practices 15-8 Temporary Tablespace: Best Practices 15-10 General Tablespace: Best Practices 15-12 Internal Fragmentation Considerations 15-13 Block Size: Advantages and Disadvantages 15-15 Sizing Redo Log Files 15-16 Automatic Statistics Gathering 15-17 Automatic Statistics Collection: Considerations 15-18 Commonly Observed Wait Events 15-19 Additional Statistics 15-20 Top 10 Mistakes Found in Oracle Systems 15-21 Summary 15-23 Appendix A: Practices Appendix B: Practice Solutions Appendix C: Services Objectives C-2 Traditional Workload Dispatching C-3 Grid Workload Dispatching C-4 What Is a Service? C-5 High Availability of Services in RAC C-6 Possible Service Configuration with RAC C-7 Service Attributes C-8 Service Types C-9 Creating Services C-10 Managing Services in a Single-Instance Environment C-11 Everything Switches to Services C-13 Using Services with Client Applications C-14 Using Services with the Resource Manager C-15 Services and Resource Manager with EM C-16 Services and the Resource Manager: Example C-17 Using Services with the Scheduler C-18 Services and the Scheduler with EM C-19 Services and the Scheduler: Example C-21 Using Services with Parallel Operations C-22 Using Services with Metric Thresholds C-23 Changing Service Thresholds by Using EM C-24

xiii

Services and Metric Thresholds: Example C-25 Service Aggregation and Tracing C-26 Top Services Performance Page C-27 Service Aggregation Configuration C-28 Service Aggregation: Example C-30 Client Identifier Aggregation and Tracing C-31 trcsess Utility C-32 Service Performance Views C-33 Generalized Trace Enabling C-35 Trace Your Own Session C-36 Practice C: Overview C-37 Summary C-38 Index

xiv

You might also like