CYAN MAGENTA YELLOW BLACK PANTONE 123 C Books for professionals by professionals ® Dear Reader, Norbert Debes is the coauthor of two books on Oracle9i database administration, development, and high availability The official documentation on the ORACLE database server is so vast that you will never manage to read it entirely Yet in all that vastness, some very useful features go completely undocumented, and others are only partially-documented Read this book, learn to apply those features, and you will lift your DBA skills to the next level Whether you are dealing with administrative tasks, performance optimization, or database security, this book will give you additional insights as well as caveats that you will not find in Oracle Corporation’s official documentation How can that be? I have been working with the ORACLE DBMS for more than 13 years and I have contributed to several documentation volumes during my tenure at Oracle I have experienced first-hand that the information flow from the developers to the documentation writers is often insufficient and that the writers have not used the features they document My favorite part of the book is about performance optimization You will learn how extended SQL trace, Statspack, AWR, and my MERITS performance optimization method all combine to really make a difference in your tuning efforts I am confident that the MERITS method and the included ESQLTRCPROF SQL trace profiler will enable you to solve performance problems that you have struggled with in the past Do not worry that the insights you will gain will soon become obsolete Most of the undocumented aspects described herein are remarkably stable I have taken great care to never write about a feature that I haven’t thoroughly tested, and to provide proof for what I say Reading this book will help set you apart from fellow DBAs by giving you just that decisive bit more that you need to solve a problem Sincerely, Norbert Debes THE APRESS ROADMAP Troubleshooting Oracle Performance Secrets of the Oracle Database Mastering Oracle SQL and SQL*Plus Expert Oracle Database 11g Administration Oracle Insights ISBN 978-1-4302-1952-1 90000 www.apress.com Debes SOURCE CODE ONLINE Beginning Oracle Database 11g Administration Secrets of the Oracle Database Secrets of the Oracle Database The EXPERT’s VOIce ® in Oracle Secrets of the Oracle Database Advanced administration, tuning, and troubleshooting using undocumented features Norbert Debes Foreword by Guy Harrison Shelve in Databases/Oracle User level: Intermediate–Advanced 781430 219521 this print for content only—size & color not accurate spine = 1.054" 552 page count Debes_1952-1FRONT.fm Page i Monday, May 11, 2009 3:30 PM Secrets of the Oracle Database ■■■ Norbert Debes Debes_1952-1FRONT.fm Page ii Monday, May 11, 2009 3:30 PM Secrets of the Oracle Database Copyright © 2009 by Norbert Debes All rights reserved No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher ISBN-13 (pbk): 978-1-4302-1952-1 ISBN-13 (electronic): 978-1-4302-1953-8 Printed and bound in the United States of America Trademarked names may appear in this book Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark Lead Editor: Jonathan Gennick Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Tony Campbell, Gary Cornell, Jonathan Gennick, Michelle Lowman, Matthew Moodie, Jeffrey Pepper, Frank Pohlmann, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Project Manager: Beth Christmas Copy Editor: Lisa Hamilton Associate Production Director: Kari Brooks-Copony Production Editor: Kelly Winquist Compositor: Susan Glinert Proofreader: Greg Teague Indexer: Norbert Debes Artist: April Milne Cover Designer: Kurt Krames Manufacturing Director: Tom Debolski Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013 Phone 1-800-SPRINGER, fax 201-348-4505, e-mail orders-ny@springer-sbm.com, or visit http://www.springeronline.com For information on translations, please contact Apress directly at 2855 Telegraph Avenue, Suite 600, Berkeley, CA 94705 Phone 510-549-5930, fax 510-549-5939, e-mail info@apress.com, or visit http:// www.apress.com Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use eBook versions and licenses are also available for most titles For more information, reference our Special Bulk Sales–eBook Licensing web page at http://www.apress.com/info/bulksales The information in this book is distributed on an “as is” basis, without warranty Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work The source code for this book is available to readers at http://www.apress.com You will need to answer questions pertaining to this book in order to successfully download the code Debes_1952-1FRONT.fm Page iii Monday, May 11, 2009 3:30 PM Debes_1952-1FRONT.fm Page iv Monday, May 11, 2009 3:30 PM Contents at a Glance Foreword xix About the Author xxi About the Foreword Writer xxiii Acknowledgments xxv Introduction xxvii PART Initialization Parameters ■CHAPTER Partially Documented Parameters ■CHAPTER Hidden Initialization Parameters 29 PART ■■■ Data Dictionary Base Tables ■CHAPTER Introduction to Data Dictionary Base Tables 41 ■CHAPTER IND$, V$OBJECT_USAGE, and Index Monitoring 45 PART ■■■ Events ■CHAPTER Event 10027 and Deadlock Diagnosis 57 ■CHAPTER Event 10046 and Extended SQL Trace 61 ■CHAPTER Event 10053 and the Cost Based Optimizer 63 ■CHAPTER Event 10079 and Oracle Net Packet Contents 87 PART iv ■■■ ■■■ X$ Fixed Tables ■CHAPTER Introduction to X$ Fixed Tables 93 ■CHAPTER 10 X$BH and Latch Contention 105 ■CHAPTER 11 X$KSLED and Enhanced Session Wait Data 113 ■CHAPTER 12 X$KFFXP and ASM Metadata 119 Debes_1952-1FRONT.fm Page v Monday, May 11, 2009 3:30 PM PART ■■■ SQL Statements ■CHAPTER 13 ALTER SESSION/SYSTEM SET EVENTS 129 ■CHAPTER 14 ALTER SESSION SET CURRENT_SCHEMA 135 ■CHAPTER 15 ALTER USER IDENTIFIED BY VALUES 143 ■CHAPTER 16 SELECT FOR UPDATE SKIP LOCKED 149 PART ■■■ Supplied PL/SQL Packages ■CHAPTER 17 DBMS_BACKUP_RESTORE 165 ■CHAPTER 18 DBMS_IJOB 173 ■CHAPTER 19 DBMS_SCHEDULER 181 ■CHAPTER 20 DBMS_SYSTEM 197 ■CHAPTER 21 DBMS_UTILITY 213 PART ■■■ Application Development ■CHAPTER 22 Perl DBI and DBD::Oracle 223 ■CHAPTER 23 Application Instrumentation and End-to-End Tracing 251 PART ■■■ Performance ■CHAPTER 24 Extended SQL Trace File Format Reference 271 ■CHAPTER 25 Statspack 311 ■CHAPTER 26 Integrating Extended SQL Trace and AWR 345 ■CHAPTER 27 ESQLTRCPROF Extended SQL Trace Profiler 351 ■CHAPTER 28 The MERITS Performance Optimization Method 371 v Debes_1952-1FRONT.fm Page vi Monday, May 11, 2009 3:30 PM PART ■■■ Oracle Net ■CHAPTER 29 TNS Listener IP Address Binding and IP=FIRST 401 ■CHAPTER 30 TNS Listener TCP/IP Valid Node Checking 413 ■CHAPTER 31 Local Naming Parameter ENABLE=BROKEN 419 ■CHAPTER 32 Default Host Name in Oracle Net Configurations 423 PART 10 ■■■ Real Application Clusters ■CHAPTER 33 Session Disconnection, Load Rebalancing, and TAF 429 ■CHAPTER 34 Removing the RAC Option Without Reinstalling 445 PART 11 ■■■ Utilities ■CHAPTER 35 OERR 459 ■CHAPTER 36 Recovery Manager Pipe Interface 465 ■CHAPTER 37 ORADEBUG SQL*Plus Command 479 PART 12 ■■■ Appendixes ■APPENDIX A Enabling and Disabling DBMS Options 495 ■APPENDIX B Bibliography 497 ■APPENDIX C Glossary 499 ■INDEX 507 vi Debes_1952-1FRONT.fm Page vii Monday, May 11, 2009 3:30 PM Contents Foreword xix About the Author xxi About the Foreword Writer xxiii Acknowledgments xxv Introduction xxvii PART ■■■ ■CHAPTER Initialization Parameters Partially Documented Parameters AUDIT_SYSLOG_LEVEL Syslog Facility Introduction to Auditing Using AUDIT_SYSLOG_LEVEL Auditing Non-Privileged Users Lessons Learned PGA_AGGREGATE_TARGET Introduction to Automatic PGA Memory Management Misconceptions About PGA_AGGREGATE_TARGET 10 Researching PGA_AGGREGATE_TARGET 11 Creating a Large Table with a Pipelined Table Function 11 V$SQL_WORKAREA_ACTIVE 12 _PGA_MAX_SIZE 16 _SMM_MAX_SIZE 17 _SMM_PX_MAX_SIZE 18 Shared Server 18 Parallel Execution 18 Lessons Learned 20 EVENT 21 Syntax 21 Leveraging Events at the Instance-Level 22 Case Study 22 vii Debes_1952-1FRONT.fm Page viii Monday, May 11, 2009 3:30 PM viii ■C O N T E N T S OS_AUTHENT_PREFIX 22 OPS$ Database Users and Password Authentication 23 Case Study 23 Lessons Learned 26 Source Code Depot 27 ■CHAPTER Hidden Initialization Parameters 29 Trace File Permissions and _TRACE_FILES_PUBLIC 30 ASM Test Environment and _ASM_ALLOW_ONLY_RAW_DISKS 31 ASM Hidden Parameters 32 Setting Up Oracle Clusterware for ASM 33 ASM Instance Setup 34 Disk Failure Simulation 37 Source Code Depot 37 PART ■■■ ■CHAPTER Data Dictionary Base Tables Introduction to Data Dictionary Base Tables 41 Large Objects and PCTVERSION vs RETENTION 42 ■CHAPTER IND$, V$OBJECT_USAGE, and Index Monitoring 45 Schema Restriction 45 Index Usage Monitoring Case Study 47 Function MONITOR_SCHEMA_INDEXES 47 Enabling Index Monitoring on Schema HR 48 Lessons Learned 52 Source Code Depot 53 PART ■■■ ■CHAPTER Events Event 10027 and Deadlock Diagnosis 57 Deadlocks 57 Event 10027 58 ■CHAPTER Event 10046 and Extended SQL Trace 61 ... Monday, May 11, 2009 3:30 PM Secrets of the Oracle Database ■■■ Norbert Debes Debes_1952-1FRONT.fm Page ii Monday, May 11, 2009 3:30 PM Secrets of the Oracle Database Copyright © 2009 by Norbert... information returned by the service The interval between the end of the previous request on the server and the beginning of the next request from the user is called think time, since the human user spends... between the moment something is initiated and the moment effects of the initiation become observable The meaning of the word is highly context dependent The term is frequently used in the context of