Oracle8 Tuning Release 8.0 December, 1997 Part No. A58246-01 Oracle8 TM Tuning Part No. A58246-01 Release 8.0 Copyright © 1997 Oracle Corporation. All Rights Reserved. Primary Author: Rita Moran Primary Contributors: Graham Wood, Anjo Kolk, Gary Hallmark Contributors: Tomohiro Akiba, David Austin, Andre Bakker, Allen Brumm, Dave Colello, Carol Col- rain, Benoit Dageville, Dean Daniels, Dinesh Das, Michael Depledge, Joyce Fee, John Frazzini, Jyotin Gautam, Jackie Gosselin, Scott Gossett, John Graham, Todd Guay, Mike Hartstein, Scott Heisey, Alex Ho, Andrew Holdsworth, Hakan Jakobssen, Sue Jang, Robert Jenkins, Jan Klokkers, Paul Lane, Dan Leary, Tirthankar Lahiri, Juan Loaiza, Diana Lorentz, George Lumpkin, Roderick Manalac, Sheryl Maring, Ravi Mirchandaney, Ken Morse, Jeff Needham, Kotaro Ono, Cetin Ozbutun, Orla Parkinson, Doug Rady, Mary Rhodes, Ray Roccaforte, Hari Sankar, Leng Leng Tan, Lawrence To, Dan Tow, Peter Vasterd, Sandy Venning, Radek Vingralek, Bill Waddington, Mohamed Zait Graphic Designer: Valarie Moore The programs are not intended for use in any nuclear, aviation, mass transit, medical, or other inher- ently dangerous applications. It shall be licensee's responsibility to take all appropriate fail-safe, back up, redundancy and other measures to ensure the safe use of such applications if the Programs are used for such purposes, and Oracle disclaims liability for any damages caused by such use of the Pro- grams. This Program contains proprietary information of Oracle Corporation; it is provided under a license agreement containing restrictions on use and disclosure and is also protected by copyright patent and other intellectual property law. Reverse engineering of the software 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. If this Program is delivered to a U.S. Government Agency of the Department of Defense, then it is deliv- ered with Restricted Rights and the following legend is applicable: Restricted Rights Legend Programs delivered subject to the DOD FAR Supplement are 'commercial computer software' and use, duplication and disclosure of the Programs 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 disclo- sure of the Programs shall be subject to the restrictions in FAR 52 227-14, Rights in Data General, including Alternate III (June 1987). Oracle Corporation, 500 Oracle Parkway, Redwood City, CA 94065. Oracle, SQL*Loader, Secure Network Services, and SQL*Plus are registered trademarks of Oracle Corporation, Redwood Shores, California. Oracle Call Interface, Oracle8, Oracle Forms, Oracle TRACE, Oracle Expert, Oracle Enterprise Manager, Oracle Enterprise Manager Performance Pack, Oracle Parallel Server, Oracle Server Manager, Net8, PL/SQL, and Pro*C are trademarks of Oracle Corporation, Redwood Shores, California. All other products or company names are used for identification purposes only, and may be trademarks of their respective owners. iii Contents Send Us Your Comments xix Preface xxi Part I Introduction 1 Introduction to Oracle Performance Tuning What Is Performance Tuning? 1-2 Trade-offs Between Response Time and Throughput 1-2 Critical Resources 1-4 Effects of Excessive Demand 1-6 Adjustments to Relieve Problems 1-7 Who Tunes? 1-8 Setting Performance Targets 1-9 Setting User Expectations 1-9 Evaluating Performance 1-10 2 Performance Tuning Method When Is Tuning Most Effective? 2-2 Proactive Tuning While Designing and Developing a System 2-2 Reactive Tuning to Improve a Production System 2-3 Prioritized Steps of the Tuning Method 2-5 Step 1: Tune the Business Rules 2-7 Step 2: Tune the Data Design 2-8 iv Step 3: Tune the Application Design 2-9 Step 4: Tune the Logical Structure of the Database 2-9 Step 5: Tune Database Operations 2-10 Step 6: Tune the Access Paths 2-10 Step 7: Tune Memory Allocation 2-11 Step 8: Tune I/O and Physical Structure 2-12 Step 9: Tune Resource Contention 2-12 Step 10: Tune the Underlying Platform(s) 2-12 How to Apply the Tuning Method 2-13 Set Clear Goals for Tuning 2-13 Create Minimum Repeatable Tests 2-14 Test Hypotheses 2-14 Keep Records 2-14 Avoid Common Errors 2-15 Stop Tuning When the Objectives Are Met 2-16 Demonstrate Meeting the Objectives 2-16 3 Diagnosing Performance Problems in an Existing System Tuning Factors for a Well-Designed Existing System 3-2 Insufficient CPU 3-5 Insufficient Memory 3-5 Insufficient I/O 3-6 Network Constraints 3-7 Software Constraints 3-7 4 Overview of Diagnostic Tools Sources of Data for Tuning 4-2 Data Volumes 4-2 Online Data Dictionary 4-3 Operating System Tools 4-3 Dynamic Performance Tables 4-3 SQL Trace Facility 4-3 Alert Log 4-3 Application Program Output 4-4 Users 4-4 v Initialization Parameter Files 4-4 Program Text 4-4 Design (Analysis) Dictionary 4-4 Comparative Data 4-5 Dynamic Performance Views 4-5 Oracle and SNMP Support 4-5 EXPLAIN PLAN 4-6 The SQL Trace Facility and TKPROF 4-6 Supported Scripts 4-6 Application Registration 4-7 Oracle Enterprise Manager Applications 4-7 Introduction to Oracle Enterprise Manager 4-7 Oracle Performance Manager 4-8 Oracle TopSessions 4-9 Oracle Trace 4-10 Oracle Tablespace Manager 4-11 Oracle Expert 4-12 Oracle Parallel Server Management 4-13 Tools You May Have Developed 4-13 Part II Designing and Developing for Performance 5 Evaluating Your System’s Performance Characteristics Types of Application 5-2 Online Transaction Processing (OLTP) 5-2 Data Warehousing 5-4 Multipurpose Applications 5-6 Oracle Configurations 5-7 Distributed Systems 5-7 The Oracle Parallel Server 5-9 Client/Server Configurations 5-9 vi 6 Designing Data Warehouse Applications Introduction 6-2 Features for Building a Data Warehouse 6-2 Parallel CREATE TABLE . . . AS SELECT 6-3 Parallel Index Creation 6-3 Fast Full Index Scan 6-3 Partitioned Tables 6-4 ANALYZE Command 6-4 Parallel Load 6-4 Features for Querying a Data Warehouse 6-5 Oracle Parallel Server Option 6-5 Parallel-Aware Optimizer 6-6 Parallel Execution 6-6 Bitmap Indexes 6-7 Star Queries 6-7 Star Transformation 6-8 Backup and Recovery of the Data Warehouse 6-8 Part III Optimizing Database Operations 7 Tuning Database Operations Tuning Goals 7-2 Tuning a Serial SQL Statement 7-2 Tuning Parallel Operations 7-3 Tuning OLTP Applications 7-4 Tuning Data Warehouse Applications 7-4 Methodology for Tuning Database Operations 7-5 Step 1: Find the Statements that Consume the Most Resources 7-5 Step 2: Tune These Statements so They Use Less Resources 7-6 Approaches to SQL Statement Tuning 7-6 Restructure the Indexes 7-7 Restructure the Statement 7-7 Restructure the Data 7-16 vii 8 Optimization Modes and Hints Using Cost-Based Optimization 8-2 When to Use the Cost-Based Approach 8-2 How to Use the Cost-Based Approach 8-3 Using Histograms for Nonuniformly Distributed Data 8-3 Generating Statistics 8-4 Choosing a Goal for the Cost-Based Approach 8-6 Parameters that Affect Cost-Based Optimization Plans 8-7 Tips for Using the Cost-Based Approach 8-9 Using Rule-Based Optimization 8-10 Introduction to Hints 8-11 How to Specify Hints 8-11 Hints for Optimization Approaches and Goals 8-14 ALL_ROWS 8-14 FIRST_ROWS 8-15 CHOOSE 8-16 RULE 8-16 Hints for Access Methods 8-17 FULL 8-17 ROWID 8-18 CLUSTER 8-18 HASH 8-18 HASH_AJ 8-19 HASH_SJ 8-19 INDEX 8-19 INDEX_ASC 8-21 INDEX_COMBINE 8-21 INDEX_DESC 8-21 INDEX_FFS 8-22 MERGE_AJ 8-22 MERGE_SJ 8-22 AND_EQUAL 8-23 USE_CONCAT 8-23 viii Hints for Join Orders 8-24 ORDERED 8-24 STAR 8-24 Hints for Join Operations 8-25 USE_NL 8-25 USE_MERGE 8-26 USE_HASH 8-27 DRIVING_SITE 8-27 Hints for Parallel Execution 8-28 PARALLEL 8-28 NOPARALLEL 8-29 APPEND 8-29 NOAPPEND 8-30 PARALLEL_INDEX 8-30 NOPARALLEL_INDEX 8-31 Additional Hints 8-32 CACHE 8-32 NOCACHE 8-32 MERGE 8-33 NO_MERGE 8-33 PUSH_JOIN_PRED 8-34 NO_PUSH_JOIN_PRED 8-34 PUSH_SUBQ 8-35 STAR_TRANSFORMATION 8-35 Using Hints with Views 8-36 Hints and Mergeable Views 8-36 Hints and Nonmergeable Views 8-37 9 Tuning Distributed Queries Remote and Distributed Queries 9-2 Remote Data Dictionary Information 9-2 Remote SQL Statements 9-3 Distributed SQL Statements 9-4 EXPLAIN PLAN and SQL Decomposition 9-7 Partition Views 9-8 ix Distributed Query Restrictions 9-12 Transparent Gateways 9-13 Summary: Optimizing Performance of Distributed Queries 9-14 10 Data Access Methods Using Indexes 10-2 When to Create Indexes 10-3 Tuning the Logical Structure 10-3 How to Choose Columns to Index 10-5 How to Choose Composite Indexes 10-6 How to Write Statements that Use Indexes 10-7 How to Write Statements that Avoid Using Indexes 10-8 Assessing the Value of Indexes 10-8 Fast Full Index Scan 10-9 Re-creating an Index 10-10 Using Existing Indexes to Enforce Uniqueness 10-11 Using Enforced Constraints 10-11 Using Bitmap Indexes 10-13 When to Use Bitmap Indexing 10-13 How to Create a Bitmap Index 10-16 Initialization Parameters for Bitmap Indexing 10-18 Using Bitmap Access Plans on Regular B*-tree Indexes 10-19 Estimating Bitmap Index Size 10-20 Bitmap Index Restrictions 10-23 Using Clusters 10-24 Using Hash Clusters 10-25 When to Use a Hash Cluster 10-25 How to Use a Hash Cluster 10-26 11 Oracle8 Transaction Modes Using Discrete Transactions 11-2 Deciding When to Use Discrete Transactions 11-2 How Discrete Transactions Work 11-3 Errors During Discrete Transactions 11-3 x Usage Notes 11-4 Example 11-4 Using Serializable Transactions 11-6 12 Managing SQL and Shared PL/SQL Areas Introduction 12-2 Comparing SQL Statements and PL/SQL Blocks 12-2 Testing for Identical SQL Statements 12-3 Aspects of Standardized SQL Formatting 12-3 Keeping Shared SQL and PL/SQL in the Shared Pool 12-4 Reserving Space for Large Allocations 12-4 Preventing Objects from Being Aged Out 12-4 Part IV Optimizing Oracle Instance Performances 13 Tuning CPU Resources Understanding CPU Problems 13-2 How to Detect and Solve CPU Problems 13-4 Checking System CPU Utilization 13-4 Checking Oracle CPU Utilization 13-6 Solving CPU Problems by Changing System Architecture 13-10 Single Tier to Two-Tier 13-11 Multi-Tier: Using Smaller Client Machines 13-11 Two-Tier to Three-Tier: Using a Transaction Processing Monitor 13-12 Three-Tier: Using Multiple TP Monitors 13-12 Oracle Parallel Server 13-13 14 Tuning Memory Allocation Understanding Memory Allocation Issues 14-2 How to Detect Memory Allocation Problems 14-3 How to Solve Memory Allocation Problems 14-3 Tuning Operating System Memory Requirements 14-4 Reducing Paging and Swapping 14-4 Fitting the System Global Area into Main Memory 14-5 [...]... Individual Users Tuning the Redo Log Buffer Tuning Private SQL and PL/SQL Areas Identifying Unnecessary Parse Calls Reducing Unnecessary Parse Calls Tuning the Shared Pool Tuning the Library Cache Tuning the Data Dictionary Cache Tuning the Shared Pool with the Multithreaded Server Tuning Reserved Space... operating system Making such adjustments is known as tuning Proper tuning of Oracle provides the best possible database performance for your specific application and hardware configuration Note: Oracle8 Tuning contains information that describes the features and functionality of the Oracle8 and the Oracle8 Enterprise Edition products Oracle8 and Oracle8 Enterprise Edition have the same basic features However,... Oracle8, the operating system, and application design before reading this manual Structure This manual contains six parts: Part 1: Introduction Chapter 1: Introduction to Oracle Performance Tuning This chapter provides an overview of tuning issues It defines performance tuning and the roles of people involved in the process Chapter 2: Performance Tuning Method This chapter presents the recommended tuning. .. integrated Oracle8 features for tuning enterprise-scale data warehouses Part 3: Writing Efficient SQL Statements Chapter 7: Tuning Database Operations This chapter explains the fundamentals of tuning database operations Chapter 8: Optimization Modes and Hints This chapter explains when to use the available optimization modes and how to use hints to enhance Oracle performance Chapter 9: Tuning Distributed... performing at its maximum potential Chapter 16: Tuning Networks This chapter introduces networking issues that affect tuning, and points to the use of array interfaces, out-of-band breaks, and other tuning techniques Chapter 17: Tuning the Operating System This chapter explains how to tune the operating system for optimal performance of Oracle Chapter 18: Tuning Resource Contention This chapter explains... 650-506-7228 Attn: Oracle8 Tuning s postal service: Oracle Corporation Server Technologies Documentation 500 Oracle Parkway, 4OP12 Redwood Shores, CA 94065 U.S.A xxviii Part I Introduction Part I provides an overview of the concepts encountered in tuning the Oracle Server The chapters in this part are: s Chapter 1, “Introduction to Oracle Performance Tuning s Chapter 2, “Performance Tuning Method” s... rises 1-4 Oracle8 Tuning What Is Performance Tuning? Time to Service Completion vs Demand Rate Time to service completion Figure 1–3 Demand Rate To manage this situation, you have two options: s You can limit demand rate to maintain acceptable response times s Alternatively, you can add multiple resources: another CPU or disk Introduction to Oracle Performance Tuning 1-5 What Is Performance Tuning? Effects... application failover, you must have the Enterprise Edition and the Parallel Server Option For information about the differences between Oracle8 and the Oracle8 Enterprise Edition and the features and options that are available to you, please refer to Getting to Know Oracle8 and the Oracle8 Enterprise Edition xxi Intended Audience This manual is an aid for people responsible for the operation, maintenance, and... Introduction to Oracle Performance Tuning The Oracle Server is a sophisticated and highly tunable software product Its flexibility allows you to make small adjustments that affect database performance By tuning your system, you can tailor its performance to best meet your needs This chapter gives an overview of tuning issues Topics in this chapter include: s What Is Performance Tuning? s Who Tunes? s Setting... Performance Tuning? s Who Tunes? s Setting Performance Targets s Setting User Expectations s Evaluating Performance Introduction to Oracle Performance Tuning 1-1 What Is Performance Tuning? What Is Performance Tuning? Performance must be built in! Performance tuning cannot be performed optimally after a system is put into production To achieve performance targets of response time, throughput, and constraints . Operations 7 Tuning Database Operations Tuning Goals 7-2 Tuning a Serial SQL Statement 7-2 Tuning Parallel Operations 7-3 Tuning OLTP Applications 7-4 Tuning. 1-10 2 Performance Tuning Method When Is Tuning Most Effective? 2-2 Proactive Tuning While Designing and Developing a System 2-2 Reactive Tuning to Improve