Oracle® Database Performance Tuning Guide 10g Release 1 (10.1) Part No. B10752-01 December 2003 Oracle Database Performance Tuning Guide, 10g Release 1 (10.1) Part No. B10752-01 Copyright © 2000, 2003 Oracle Corporation. All rights reserved. Graphic Designer: Valarie Moore Contributors: James Barlow, Vladimir Barriere, Eric Belden, Qiang Cao, Sunil Chakkappen, Sumanta Chatterjee, Alvaro Corena, Benoit Dageville, Dinesh Das, Karl Dias, Vinayagam Djegaradjane, Harvey Eneman, Bjorn Engsig, Mike Feng, Cecilia Gervasio, Bhaskar Ghosh, Ray Glasstone, Leslie Gloyd, Connie Dialeris Green, Joan Gregoire, Lester Gutierrez, Lex de Haan, Karl Haas, Brian Hirano, Lilian Hobbs, Andrew Holdsworth, Mamdouh Ibrahim, Hakan Jacobsson, Christopher Jones, Srinivas Kareenhalli, Feroz Khan, Stella Kister, Herve Lejeune, Yunrui Li, Juan Loaiza, Diana Lorentz, George Lumpkin, Joe McDonald, Bill McKenna, Mughees Minhas, Sujatha Muthulingam, Gary Ngai, Michael Orlowski, Kant C. Patel, Richard Powell, Mark Ramacher, Shankar Raman, Uri Shaft, Vinay Srihari, Sankar Subramanian, Margaret Susairaj, Hal Takahara, Venkateshwaran Venkataramani, Nitin Vengurlekar, Stephen Vivian, Simon Watt, Andrew Witkowski, Graham Wood, Khaled Yagoub, and Mohamed Zait The Programs (which include both the software and documentation) contain proprietary information of Oracle Corporation; they are provided under a license agreement containing restrictions on use and disclosure and are also protected by copyright, patent and other intellectual and industrial property laws. Reverse engineering, disassembly or decompilation of the Programs, except to the extent required to obtain interoperability with other independently created software or as specified by law, is prohibited. The information contained in this document is subject to change without notice. If you find any problems in the documentation, please report them to us in writing. Oracle Corporation does not warrant that this document is error-free. Except as may be expressly permitted in your license agreement for these Programs, no part of these Programs may be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without the express written permission of Oracle Corporation. If the Programs are delivered to the U.S. Government or anyone licensing or using the programs on behalf of the U.S. Government, the following notice is applicable: Restricted Rights Notice Programs delivered subject to the DOD FAR Supplement are "commercial computer software" and use, duplication, and disclosure of the Programs, including documentation, shall be subject to the licensing restrictions set forth in the applicable Oracle license agreement. Otherwise, Programs delivered subject to the Federal Acquisition Regulations are "restricted computer software" and use, duplication, and disclosure of the Programs shall be subject to the restrictions in FAR 52.227-19, Commercial Computer Software - Restricted Rights (June, 1987). Oracle Corporation, 500 Oracle Parkway, Redwood City, CA 94065. The Programs are not intended for use in any nuclear, aviation, mass transit, medical, or other inherently dangerous applications. It shall be the licensee's responsibility to take all appropriate fail-safe, backup, redundancy, and other measures to ensure the safe use of such applications if the Programs are used for such purposes, and Oracle Corporation disclaims liability for any damages caused by such use of the Programs. Oracle is a registered trademark, and Oracle Store, Oracle9i, PL/SQL, SQL*Net, and SQL*Plus are trademarks or registered trademarks of Oracle Corporation. Other names may be trademarks of their respective owners. iii Contents Send Us Your Comments xv Preface xvii Audience xviii Organization xviii Related Documentation xxi Conventions xxii Documentation Accessibility xxiv What's New in Oracle Performance? xxvii Oracle Database 10g Release 1 (10.1) New and Updated Features for Performance Tuning xxviii Part I Performance Tuning 1 Performance Tuning Overview Introduction to Performance Tuning 1-2 Performance Planning 1-2 Instance Tuning 1-2 SQL Tuning 1-5 Introduction to Performance Tuning Features and Tools 1-6 Automatic Performance Tuning Features 1-7 Additional Oracle Tools 1-8 iv Part II Performance Planning 2 Designing and Developing for Performance Oracle Methodology 2-2 Understanding Investment Options 2-2 Understanding Scalability 2-3 What is Scalability? 2-3 System Scalability 2-4 Factors Preventing Scalability 2-5 System Architecture 2-7 Hardware and Software Components 2-7 Configuring the Right System Architecture for Your Requirements 2-10 Application Design Principles 2-13 Simplicity In Application Design 2-13 Data Modeling 2-14 Table and Index Design 2-14 Using Views 2-17 SQL Execution Efficiency 2-17 Implementing the Application 2-19 Trends in Application Development 2-21 Workload Testing, Modeling, and Implementation 2-22 Sizing Data 2-22 Estimating Workloads 2-23 Application Modeling 2-24 Testing, Debugging, and Validating a Design 2-24 Deploying New Applications 2-26 Rollout Strategies 2-26 Performance Checklist 2-27 3 Performance Improvement Methods The Oracle Performance Improvement Method 3-2 Steps in The Oracle Performance Improvement Method 3-3 A Sample Decision Process for Performance Conceptual Modeling 3-5 Top Ten Mistakes Found in Oracle Systems 3-6 v Emergency Performance Methods 3-8 Steps in the Emergency Performance Method 3-9 Part III Optimizing Instance Performance 4 Configuring a Database for Performance Performance Considerations for Initial Instance Configuration 4-2 Initialization Parameters 4-2 Configuring Undo Space 4-4 Sizing Redo Log Files 4-5 Creating Subsequent Tablespaces 4-5 Creating and Maintaining Tables for Good Performance 4-7 Table Compression 4-8 Reclaiming Unused Space 4-9 Indexing Data 4-9 Performance Considerations for Shared Servers 4-10 Identifying Contention Using the Dispatcher-Specific Views 4-11 Identifying Contention for Shared Servers 4-13 5 Automatic Performance Statistics Overview of Data Gathering 5-2 Database Statistics 5-3 Operating System Statistics 5-5 Interpreting Statistics 5-8 Automatic Workload Repository 5-10 Accessing the Automatic Workload Repository with Oracle Enterprise Manager 5-12 Managing Snapshot and Baseline Data with APIs 5-13 Workload Repository Views 5-16 Workload Repository Reports 5-17 6 Automatic Performance Diagnostics Introduction to Database Diagnostic Monitoring 6-2 Automatic Database Diagnostic Monitor 6-3 ADDM Analysis Results 6-4 vi An ADDM Example 6-5 Setting Up ADDM 6-6 Accessing ADDM with Oracle Enterprise Manager 6-7 Diagnosing Database Performance Issues with ADDM 6-8 Views with ADDM Information 6-12 7 Memory Configuration and Use Understanding Memory Allocation Issues 7-2 Oracle Memory Caches 7-2 Automatic Shared Memory Management 7-3 Dynamically Changing Cache Sizes 7-4 Application Considerations 7-6 Operating System Memory Use 7-6 Iteration During Configuration 7-7 Configuring and Using the Buffer Cache 7-8 Using the Buffer Cache Effectively 7-8 Sizing the Buffer Cache 7-8 Interpreting and Using the Buffer Cache Advisory Statistics 7-12 Considering Multiple Buffer Pools 7-14 Buffer Pool Data in V$DB_CACHE_ADVICE 7-16 Buffer Pool Hit Ratios 7-17 Determining Which Segments Have Many Buffers in the Pool 7-17 KEEP Pool 7-19 RECYCLE Pool 7-20 Configuring and Using the Shared Pool and Large Pool 7-20 Shared Pool Concepts 7-21 Using the Shared Pool Effectively 7-24 Sizing the Shared Pool 7-29 Interpreting Shared Pool Statistics 7-35 Using the Large Pool 7-36 Using CURSOR_SPACE_FOR_TIME 7-40 Caching Session Cursors 7-41 Configuring the Reserved Pool 7-42 Keeping Large Objects to Prevent Aging 7-44 CURSOR_SHARING for Existing Applications 7-45 vii Maintaining Connections 7-47 Configuring and Using the Redo Log Buffer 7-48 Sizing the Log Buffer 7-49 Log Buffer Statistics 7-49 PGA Memory Management 7-50 Configuring Automatic PGA Memory 7-52 Configuring OLAP_PAGE_POOL_SIZE 7-68 8 I/O Configuration and Design Understanding I/O 8-2 Basic I/O Configuration 8-2 Lay Out the Files Using Operating System or Hardware Striping 8-2 Manually Distributing I/O 8-6 When to Separate Files 8-7 Three Sample Configurations 8-9 Oracle-Managed Files 8-10 Choosing Data Block Size 8-11 9 Understanding Operating System Resources Understanding Operating System Performance Issues 9-2 Using Operating System Caches 9-2 Memory Usage 9-3 Using Operating System Resource Managers 9-4 Solving Operating System Problems 9-5 Performance Hints on UNIX-Based Systems 9-6 Performance Hints on Windows Systems 9-6 Performance Hints on Midrange and Mainframe Computers 9-6 Understanding CPU 9-7 Context Switching 9-9 Finding System CPU Utilization 9-10 Checking Memory Management 9-10 Checking I/O Management 9-11 Checking Network Management 9-11 Checking Process Management 9-11 viii 10 Instance Tuning Using Performance Views Instance Tuning Steps 10-2 Define the Problem 10-3 Examine the Host System 10-4 Examine the Oracle Statistics 10-7 Implement and Measure Change 10-12 Interpreting Oracle Statistics 10-13 Examine Load 10-13 Using Wait Event Statistics to Drill Down to Bottlenecks 10-14 Table of Wait Events and Potential Causes 10-16 Additional Statistics 10-18 Wait Events Statistics 10-21 SQL*Net Events 10-23 buffer busy waits 10-25 db file scattered read 10-27 db file sequential read 10-29 direct path read and direct path read temp 10-31 direct path write and direct path write temp 10-33 enqueue (enq:) waits 10-34 free buffer waits 10-37 latch events 10-40 log file parallel write 10-45 library cache pin 10-45 library cache lock 10-45 log buffer space 10-46 log file switch 10-46 log file sync 10-47 rdbms ipc reply 10-48 Idle Wait Events 10-48 11 Tuning Networks Understanding Connection Models 11-2 Shared Server Configuration 11-2 Detecting Network Problems 11-6 Using Dynamic Performance Views for Network Performance 11-6 ix Understanding Latency and Bandwidth 11-7 Solving Network Problems 11-8 Finding Network Bottlenecks 11-9 Dissecting Network Bottlenecks 11-10 Using Array Interfaces 11-13 Adjusting Session Data Unit Buffer Size 11-14 Using TCP.NODELAY 11-14 Using Connection Manager 11-14 Part IV Optimizing SQL Statements 12 SQL Tuning Overview Introduction to SQL Tuning 12-2 Goals for Tuning 12-2 Reduce the Workload 12-2 Balance the Workload 12-3 Parallelize the Workload 12-3 Identifying High-Load SQL 12-3 Identifying Resource-Intensive SQL 12-3 Gathering Data on the SQL Identified 12-5 Automatic SQL Tuning Features 12-6 Developing Efficient SQL Statements 12-7 Verifying Optimizer Statistics 12-8 Reviewing the Execution Plan 12-8 Restructuring the SQL Statements 12-9 Controlling the Access Path and Join Order with Hints 12-17 Restructuring the Indexes 12-21 Modifying or Disabling Triggers and Constraints 12-22 Restructuring the Data 12-22 Maintaining Execution Plans Over Time 12-22 Visiting Data as Few Times as Possible 12-22 x 13 Automatic SQL Tuning Automatic SQL Tuning Overview 13-2 Query Optimizer Modes 13-2 Types of Tuning Analysis 13-2 SQL Tuning Advisor 13-6 Input Sources 13-6 Tuning Options 13-7 Advisor Output 13-7 Accessing the SQL Tuning Advisor with Oracle Enterprise Manager 13-7 Using SQL Tuning Advisor APIs 13-8 Managing SQL Profiles with APIs 13-10 Accepting a SQL Profile 13-11 Altering a SQL Profile 13-11 Dropping a SQL Profile 13-11 SQL Tuning Sets 13-12 Accessing SQL Tuning Sets with Oracle Enterprise Manager 13-12 Managing SQL Tuning Sets 13-13 SQL Tuning Information Views 13-16 14 The Query Optimizer Optimizer Operations 14-2 Choosing an Optimizer Goal 14-3 OPTIMIZER_MODE Initialization Parameter 14-4 Optimizer SQL Hints for Changing the Query Optimizer Goal 14-5 Query Optimizer Statistics in the Data Dictionary 14-6 Enabling and Controlling Query Optimizer Features 14-6 Enabling Query Optimizer Features 14-6 Controlling the Behavior of the Query Optimizer 14-8 Understanding the Query Optimizer 14-9 Components of the Query Optimizer 14-10 Reading and Understanding Execution Plans 14-15 Understanding Access Paths for the Query Optimizer 14-18 Full Table Scans 14-18 Rowid Scans 14-20 Index Scans 14-21 [...]... 1, "Performance Tuning Overview" 1 Performance Tuning Overview This chapter provides an introduction to performance tuning This chapter contains the following: s Introduction to Performance Tuning s Introduction to Performance Tuning Features and Tools Performance Tuning Overview 1-1 Introduction to Performance Tuning Introduction to Performance Tuning This guide provides information on tuning an Oracle. .. Day DBA manual Organization This document contains: "What's New in Oracle Performance? " A summary of recent enhancements to Oracle Performance and updates to this book Part I, "Performance Tuning" This part of the book provides an introduction and overview of performance tuning Chapter 1, "Performance Tuning Overview" An introduction to performance tuning Part II, "Performance Planning" This part of... TKPROF, two basic performance diagnostic tools that can help you monitor and tune applications that run against the Oracle Server Related Documentation Before reading this manual, you should have already read Oracle Database Concepts, Oracle 2 Day DBA, Oracle Database Application Developer's Guide - Fundamentals, and the Oracle Database Administrator's Guide For more information about Oracle Enterprise... local Oracle Support Services xv xvi Preface This preface contains these topics: s Audience s Organization s Related Documentation s Conventions s Documentation Accessibility xvii Audience Oracle Database Performance Tuning Guide is an aid for people responsible for the operation, maintenance, and performance of Oracle This book describes detailed ways to enhance Oracle performance by writing and tuning. .. information on tuning an Oracle Database system for performance Topics discussed in this guide include: s Performance Planning s Instance Tuning s SQL Tuning Performance Planning Before you start on the instance or SQL tuning sections of this guide, make sure you have read Part II, "Performance Planning" Based on years of designing and performance experience, Oracle has designed a performance methodology This... information regarding instance and database performance This chapter discusses the importance of performance data gathering and describes the available Oracle features Chapter 6, "Automatic Performance Diagnostics" Oracle provides a number of tools that allow a performance engineer to monitor and diagnose database performance This chapter describes the available Oracle features and tools Chapter 7,... SQL properly, using performance tools, and optimizing instance performance It also explains how to create an initial database for good performance and includes performance- related reference information This book could be useful for database administrators, application designers, and programmers For information on quick and easy monitoring and tuning of the Oracle database, read the Oracle 2 Day DBA manual... Oracle Database 10g Release 1 (10.1) and provides pointers to additional information The features and enhancements described in this section comprise the overall effort to optimize server performance For a summary of all new features for Oracle Database 10g Release 1 (10.1), see Oracle Database New Features xxvii Oracle Database 10g Release 1 (10.1) New and Updated Features for Performance Tuning The... ways to improve Oracle performance by starting with good application design and using statistics to monitor application performance It explains the Oracle Performance Improvement Method, as well as emergency performance techniques for dealing with performance problems Chapter 2, "Designing and Developing for Performance" This chapter describes performance issues to consider when designing Oracle applications... Chapter 3, "Performance Improvement Methods" This chapter describes Oracle Performance Improvement Methods Part III, "Optimizing Instance Performance" This part of the book describes how to create and configure a database for good performance This section provides information about Oracle system-related performance tools and describes how to tune various elements of a database system to optimize performance . Oracle Database Performance Tuning Guide 10g Release 1 (10.1) Part No. B10752-01 December 2003 Oracle Database Performance Tuning Guide, 10g. Updated Features for Performance Tuning xxviii Part I Performance Tuning 1 Performance Tuning Overview Introduction to Performance Tuning 1-2 Performance Planning