® Oracle Performance Tuning and Optimization Edward Whalen 201 West 103rd Street Indianapolis, Indiana 46290 i To my father Oracle Performance Tuning & Optimization Acquisitions Editor Copyright 1996 by Sams Publishing FIRST EDITION All rights reserved No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher No patent liability is assumed with respect to the use of the information contained herein Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions Neither is any liability assumed for damages resulting from the use of the information contained herein For information, address Sams Publishing, 201 W 103rd St., Indianapolis, IN 46290 International Standard Book Number: 0-672-30866-X Library of Congress Catalog Card Number: 95-72345 99 98 97 96 Development Editors Byron Pearce Todd Bumbalough Software Development Specialist Steve Flatt Production Editor Alice Martina Smith Technical Reviewers David Kennedy Stephen Tallon Editorial Coordinator Bill Whitmer Interpretation of the printing code: the rightmost double-digit number is the year of the book’s printing; the rightmost single-digit, the number of the book’s printing For example, a printing code of 96-1 shows that the first printing of the book occurred in 1996 Composed in AGaramond and MCPdigital by Macmillan Computer Publishing Printed in the United States of America Technical Edit Coordinator Lynette Quinn Formatter Frank Sinclair Editorial Assistants All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized Sams Publishing cannot attest to the accuracy of this information Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark Publisher and President: Acquisitions Manager: Development Manager: Managing Editor: Marketing Manager: Rosemarie Graham Sharon Cox Andi Richter Rhonda Tinch-Mize Cover Designer Tim Amrhein Richard K Swadley Greg Wiegand Dean Miller Cindy Morrow Gregg Bushyeager Book Designer Alyssa Yesh Copy Writer Peter Fuller Production Team Supervisor Brad Chinn Production ii Mary Ann Abramson Georgianna Briggs Jama Carter Amy Chinn Michael Dietsch Jason Hand Sonja Hart Ayanna Lacey Clint Lahnen Paula Lowell Brian-Kent Proffitt Bobbi Satterfield Susan Van Ness Colleen Williams Overview PART I PART II 10 11 12 13 14 15 PART III 16 17 18 19 20 21 22 23 PART IV 24 25 26 27 28 29 30 31 32 Introduction xxiv Introduction Introduction to Oracle Understanding Terms 21 What Is a Well-Tuned System? 31 Tuning Methodology 41 Benchmarking 51 Performance Monitoring Tools 73 Performance Engineering Starts at the Design Stage 81 Tuning the Server 89 What Affects Oracle Server Performance? 91 Oracle Instance Tuning 97 Performance Enhancements 139 Tuning the Server Operating System 167 Operating System-Specific Tuning 177 System Processors 205 Advanced Disk I/O Concepts 213 Disk Arrays 225 Configuring the System 243 OLTP System 245 Batch Processing System 265 Decision Support System 285 Data Warehousing System 303 BLOB System 323 The Oracle Parallel Server System 339 Optimal Backup and Recovery 349 Miscellaneous Configurations 367 Tuning SQL 391 What Is a Well-Tuned SQL Statement? 393 Using EXPLAIN PLAN and SQL Trace 403 Tuning SQL Statements 419 Using the Oracle Optimizer 437 Using Procedures, Functions, and Packages 449 Providing for Data Integrity and Triggers 461 Using Hints 475 Introducing SQL Development Tools 489 Miscellaneous SQL Topics 501 iii Oracle Performance Tuning & Optimization PART V Tuning the Client 513 33 34 35 36 PART VI 37 38 PART VII A B C D E F iv What Affects Client Performance? 515 Tuning the Client System 525 Using GUI Builders 533 Using Middleware Products 555 Tuning the Network 563 What Affects Network Performance? 565 Tuning the Network Components 573 References 579 Review of Tuning Guidelines 581 Quick Reference 595 Flowcharts 603 Glossary 607 Oracle Tuning Parameters 619 Contents of the CD-ROM 645 Index 649 Contents Introduction xxiv Part I Introduction 1 Introduction to Oracle The Database The Physical Layer The Logical Layer The Oracle Instance The Oracle Memory Structure System Global Area (SGA) Program Global Area (PGA) 10 Processes 10 How Transactions Work 12 Oracle Products 13 Oracle RDBMS Products 13 Oracle Workgroup Server 15 Personal Oracle for Windows 16 Oracle Development Tools 16 Oracle Applications 17 Oracle Services 18 Summary 19 Understanding Terms 21 Terms 22 RDBMS Functionality 26 Checkpoint 26 Logging and Archiving 26 Business Models 27 OnLine Transaction Processing (OLTP) 27 Batch Processing 27 Decision Support 28 Data Warehousing 28 Binary Large Objects (BLOBs) 28 Unit Conversions 28 Powers of 10 29 Storage Units 29 Summary 30 What Is a Well-Tuned System? 31 Client/Server Computing 32 The Client or Front-End Machines 33 The Server 33 The Network 35 Client/Server Checklist 35 v virtual memory memory buffer cache, 107-108 operating system, 99 private PL/SQL areas, 100 private SQL areas, 100 shared pool, 100-106 methodology, 44 analyzing results, 50 determing solution to problems, 48-49 examining system for problems, 45-46 finding cause or performance problems, 47-48 goal setting for optimal performance, 48-50 performance clients, 85 networks, 85-86 servers, 85 Tuxedo systems, features, 344 two-phase commit, 617 two-tiered system architecture, 556 U UNIQUE constraint, 465 unique indexes, 149, 427 units of measurements, conversions, 28 binary storage units, 29-30 powers of 10, 29 UNIX, 530-531 architecture, 192 development of, 191 I/O subsystem, 197-198 asynchronous I/O, 198-200 file system, 198 raw device interface, 198 memory, 192-193, 531 reducing unnecessary memory usage, 193 SGA tuning, 194-195 user capacity, 195-196 networks, 196, 531 SCO UNIX, 196-197 Solaris, 197 tuning, 575 UnixWare, 197 new features benchmarking, 200 cache affinity, 202 disabling preemptive scheduling, 201 ISM (Intimate Shared Memory), 201 load balancing, 202 post-wait semaphores, 201 parameters asynchronous I/O, 198 SHMMAX, 194 SHMSEG, 194 summary of tuning guidelines, 202-203 UNIX SVR4, 191 UnixWare buffer cache, tuning, 193 networks, 197 parameters asynchronous I/O, 199 shared memory, 194-195 updatable snapshots, 374 UPDATE statement defined, 617 execution plan, displaying with EXPLAIN PLAN command, 414-416 updating rollback segments, 128 USE_CONCAT hint, 483-484 USE_MERGE hint, 484 USE_NL hint, 485 user processes (client processes), 10 user-transaction profile, flowchart, 605 USER_CONS_COLUMNS view, 467 USER_CONSTRAINTS view, 467 USER_DUMP_DEST parameter, 405, 637 USER_TRIGGERS view, 471 V V$FILESTAT dynamic performance table, disk access information, 597 V$LATCH dynamic performance table, latch contention data, 601 V$ROLLSTAT dynamic performance table, dynamic rollback growth data, 600 V$ROLLSTAT table, rollback segment data, 129 V$ROWCACHE table, data dictionary statistics, 103 V$SYSSTAT dynamic performance table, recursive calls data, 599 V$SYSSTAT table, buffer cache statistics, 107 V$WAITSTAT dynamic performance table, rollback contention data, 599 V$WAITSTAT table, rollback segment data, 127 validating data, triggers, 469 VARCHAR2 data type, 510 variables, binding, 401 viewing constraints, 467-469 triggers, 471-472 views defined, 6, 617 dynamic performance tables, 74-75 virtual memory defined, 25, 211, 617 paging, 24, 211 swapping, 25, 211 681 warehouses W-X-Y-Z warehouses, see data warehouses WebServer system archive logs, 389 block buffers, 388 size, 389 characteristics, 386-387 checkpoints, 389 clusters, 389 contention, latch and rollback, 389 defined, 18, 368, 386 design considerations, 387-388 enhancements, 389-390 hash clusters, 389 library cache, 388 682 multiblock reads, 389 Parallel Query option, 389 Parallel Server option, 389 spin counts, 388 summary, 390 tuning considerations, 388-389 Windows 3.1 memory, 528 networks, 528-529 Windows 95 32-bit support, 529-530 memory, 530 networks, 530 Oracle support, 530 Windows for Workgroups 3.11 memory, 528 networks, 528-529 Windows NT, 183 16-bit applications, 527 architecture, 183-184 defined, 527 I/O performance, 528 I/O subsystem, 186-187 memory, 185, 527 reducing unnecessary memory usage, 185 SGA tuning, 185-186 user capacity, 186 networks, 186 tuning, 575 summary of tuning guidelines, 187 threads, 184 words, 29 Workgroup Server, 15-16 write caches, disk arrays, 228-229 ... Tools 73 Performance Engineering Starts at the Design Stage 81 Tuning the Server 89 What Affects Oracle Server Performance? 91 Oracle Instance Tuning 97 Performance Enhancements... 501 iii Oracle Performance Tuning & Optimization PART V Tuning the Client 513 33 34 35 36 PART VI 37 38 PART VII A B C D E F iv What Affects Client Performance? 515 Tuning the Client... 12 Oracle Products 13 Oracle RDBMS Products 13 Oracle Workgroup Server 15 Personal Oracle for Windows 16 Oracle Development Tools 16 Oracle