Oracle Performance Tuning and Optimization Oracle Performance Tuning and Optimization Edward Whalen 201 West 103rd Street Indianapolis, Indiana 46290 ®... No part of this book shall be r
Trang 1Oracle
Performance Tuning and Optimization
Oracle
Performance Tuning and Optimization
Edward Whalen
201 West 103rd Street Indianapolis, Indiana 46290
®
Trang 2Oracle Performance Tuning & Optimization
Publisher and President: Richard K Swadley Acquisitions Manager: Greg Wiegand Development Manager: Dean Miller Managing Editor: Cindy Morrow Marketing Manager: Gregg Bushyeager
To my father.
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 4 3 2 1
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
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.
Acquisitions Editor
Rosemarie Graham
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
Technical Edit Coordinator
Lynette Quinn
Formatter
Frank Sinclair
Editorial Assistants
Sharon Cox Andi Richter Rhonda Tinch-Mize
Cover Designer
Tim Amrhein
Book Designer
Alyssa Yesh
Copy Writer
Peter Fuller
Production Team Supervisor
Brad Chinn
Production
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
Trang 3Overview
Introduction xxiv
PART I Introduction 1 1 Introduction to Oracle 3
2 Understanding Terms 21
3 What Is a Well-Tuned System? 31
4 Tuning Methodology 41
5 Benchmarking 51
6 Performance Monitoring Tools 73
7 Performance Engineering Starts at the Design Stage 81
PART II Tuning the Server 89 8 What Affects Oracle Server Performance? 91
9 Oracle Instance Tuning 97
10 Performance Enhancements 139
11 Tuning the Server Operating System 167
12 Operating System-Specific Tuning 177
13 System Processors 205
14 Advanced Disk I/O Concepts 213
15 Disk Arrays 225
PART III Configuring the System 243 16 OLTP System 245
17 Batch Processing System 265
18 Decision Support System 285
19 Data Warehousing System 303
20 BLOB System 323
21 The Oracle Parallel Server System 339
22 Optimal Backup and Recovery 349
23 Miscellaneous Configurations 367
PART IV Tuning SQL 391 24 What Is a Well-Tuned SQL Statement? 393
25 Using EXPLAIN PLAN and SQL Trace 403
26 Tuning SQL Statements 419
27 Using the Oracle Optimizer 437
28 Using Procedures, Functions, and Packages 449
29 Providing for Data Integrity and Triggers 461
30 Using Hints 475
31 Introducing SQL Development Tools 489
32 Miscellaneous SQL Topics 501
Trang 4Oracle Performance Tuning & Optimization
PART V Tuning the Client 513
33 What Affects Client Performance? 515
34 Tuning the Client System 525
35 Using GUI Builders 533
36 Using Middleware Products 555
PART VI Tuning the Network 563 37 What Affects Network Performance? 565
38 Tuning the Network Components 573
PART VII References 579 A Review of Tuning Guidelines 581
B Quick Reference 595
C Flowcharts 603
D Glossary 607
E Oracle Tuning Parameters 619
F Contents of the CD-ROM 645
Index 649
Trang 5Contents
Introduction xxiv
Part I Introduction 1 1 Introduction to Oracle 3
The Database 4
The Physical Layer 4
The Logical Layer 5
The Oracle Instance 8
The Oracle Memory Structure 8
System Global Area (SGA) 9
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
2 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
3 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
Trang 6buffer 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
virtual memory
Trang 7W-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
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
warehouses
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