Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 709 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
709
Dung lượng
26,82 MB
Nội dung
i
Oracle
Performance Tuning
and Optimization
Oracle
Performance Tuning
and Optimization
Edward Whalen
201 West 103rd Street
Indianapolis, Indiana 46290
®
ii
Oracle 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
Susan Van Ness
Colleen Williams
iii
Overview
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
iv
Oracle 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
v
Contents
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
vi
Oracle Performance Tuning & Optimization
Host-Based Computing 36
The Front-End Application 36
The Database 36
Terminal-Based Checklist 37
Batch Computing 38
Batch-Processing Checklist 39
Exceptions 39
Multimedia Systems 39
Shipping Systems 39
Summary 40
4 Tuning Methodology 41
Goals 42
Throughput 42
Response Time 42
Connectivity 43
Fault Tolerance 43
Load Time 44
Tuning Methodology 44
Examine the Problem 45
Determine the Problem 47
Determine the Solution and Set Goals 48
Test the Solution 49
Analyze the Results 50
Summary 50
5 Benchmarking 51
Introduction to Benchmarking 52
Industry Standard Benchmarks 52
The Transaction Processing Performance Council (TPC) 53
TPC Rules and Regulations 55
Results 56
Benchmarks 57
Publication Benchmarks 69
Custom Benchmarks 70
Writing Your Own Benchmark 70
Summary 72
6 Performance Monitoring Tools 73
Oracle Tools 75
SQL*DBA Monitor 76
Server Manager 76
Oracle SNMP Agents 76
SQL Trace 76
EXPLAIN PLAN 77
vii
Contents
OS Tools 77
Third-Party Tools 78
Real-Time Monitors 79
Threshold Monitors 79
Summary 80
7 Performance Engineering Starts at the Design Stage 81
Design Stage 82
Database Layout 82
Indexes and Clusters 83
Application Design 83
Hardware Sizing 83
Network Considerations 84
Performance Tuning after the System Is Built 84
Tuning the Client 85
Tuning the Server 85
Tuning the Network 85
Summary 86
Part II Tuning the Server 89
8 What Affects Oracle Server Performance? 91
System Bottlenecks 92
Finding the Bottleneck 92
Removing the Bottleneck 93
System Tuning 93
Tuning RDBMS Resources 93
Tuning OS Resources 94
Tuning Hardware Resources 94
Other Tuning Factors 95
System Limitations 95
Summary 95
9 Oracle Instance Tuning 97
Tuning Memory 98
Tuning the Operating System 99
Tuning the Private SQL and PL/SQL Areas 100
Tuning the Shared Pool 100
Tuning the Buffer Cache 107
Tuning the I/O Subsystem 108
Understanding Disk Contention 109
Identifying Disk Contention Problems 110
Solving Disk Contention Problems 111
Reducing Unnecessary I/O Overhead 117
Migrated and Chained Rows 117
Dynamic Extensions 118
viii
Oracle Performance Tuning & Optimization
PCTFREE and PCTUSED Command Options 119
A Review of I/O Reduction Techniques 122
Tuning Rollback Segments 123
Understanding How Rollback Segments Work 123
Tuning Rollback Segments 126
Review of Rollback Segment Tuning 130
Checking for Latch Contention 130
Redo Log Buffer Contention 130
Redo Log Buffer Latch Contention 131
Tuning Checkpoints 133
Optimizing Archiving 134
Adjusting the Effect of Archiving 135
Optimizing Sorts 135
Minimizing Free List Contention 136
Summary 137
10 Performance Enhancements 139
Block Size 140
Clusters 141
Direct-Write Sorts 143
Fragmentation 144
Hash Clusters 146
When To Hash 147
Indexes 148
Index Types 149
How the Oracle Index Works 149
What To Index 150
Multiblock Reads 152
Multiblock Writes 152
Parallel Query Option 153
Parallel Query Processing 153
Direct-Write Sorts 158
Parallel Index Creation 159
Parallel Loading 159
Parallel Recovery 160
Parallel Server Option 161
Spin Counts 164
Summary 164
11 Tuning the Server Operating System 167
Goals 168
Processes 169
Memory 170
I/O 170
ix
Contents
Direct or Synchronous I/O 172
Asynchronous I/O 172
Miscellaneous 173
Post-Wait Semaphore 173
Scheduling and Preemption 173
Cache Affinity 174
Summary 174
12 Operating System-Specific Tuning 177
NetWare 178
Architectural Overview 178
Tuning Considerations 179
Windows NT 183
Architectural Overview 183
Tuning Considerations 185
OS/2 188
Architectural Overview 188
Tuning Considerations 188
UNIX 191
Architectural Overview 192
Tuning Considerations 192
Summary 203
13 System Processors 205
Overview of Computer Architecture 206
CPU and Cache 206
CPU Design 207
CISC Processors 207
RISC Processors 208
Multiprocessor Systems 209
SMP Systems 209
MPP Systems 209
CPU Cache 210
System Memory Architecture 210
Virtual Memory System 211
Bus Design 211
Summary 212
14 Advanced Disk I/O Concepts 213
Disk Operation 214
Seek Time 216
Rotational Latency 217
Data Transfer Rate 217
Queue Time 218
x
Oracle Performance Tuning & Optimization
Disk Performance 219
Random I/Os 220
Sequential I/Os 220
Summary 223
15 Disk Arrays 225
How Does a Disk Array Work? 226
Software Array 227
Hardware Array 227
RAID Technology 229
RAID-0 230
RAID-1 230
RAID-2 231
RAID-3 231
RAID-4 232
RAID-5 232
Fault-Tolerance Concerns 233
No Data Protection 233
Full Data Protection 234
Partial Data Protection 234
Configuring RAID for RDBMS Performance 235
Isolate Sequential I/Os 236
Distribute Random I/Os 237
Size the Volume Properly 238
Configure for the Disk Array 240
RAID Comparison 240
Summary 241
Part III Configuring the System 243
16 OLTP System 245
Characteristics of the OLTP System 246
Data Access Patterns 246
System Load 247
Goals 248
Design Considerations 249
Physical Data Layout 250
Hardware Considerations 253
Tuning Considerations 253
Oracle Tuning 254
Server OS Tuning 255
Enhancements 256
Oracle Parallel Server Option 257
Hardware Enhancements 257
[...]... determine where performance can be enhanced Chapter 8, “What Affects Oracle Server Performance? ” is an overview of what can effect the server performance and where bottlenecks can occur Chapter 9, Oracle Instance Tuning, reviews the bulk of instance tuning Items such as memory, I/O, and CPU usage are discussed here You also get a more in-depth look at some internal Oracle structures Chapter 10, Performance. .. associated with Oracle are the System Global Area (SGA) and the Program Global Area (PGA) 8 Chapter 1 x Introduction to Oracle Figure 1.4 The Oracle instance System Global Area (SGA) The SGA is a shared memory region Oracle uses to store data and control information for one Oracle instance The SGA is allocated when the Oracle instance starts; it is deallocated when the Oracle instance shuts down Each Oracle. .. introduced to the Transaction Processing Performance Council (TCP), their Web site, and how you can use the information available Chapter 6, Performance Monitoring Tools,” provides an overview of some of the performance monitoring tools available from Oracle and third-party vendors The chapter explains how these tools can help you investigate performance problems Chapter 7, Performance Engineering Starts at... Design Stage,” explains the holistic approach to performance engineering Performance should be engineered into every aspect of the system—from hardware selection and network configuration to database design and application development 2 Chapter 1 x Introduction to Oracle 1 Chapter Introduction to Oracle To effectively enhance the performance of your Oracle system, it is essential to understand how... are introduced to the Transaction Processing Performance Council (TCP), their Web site, and how you can use this information Chapter 6, Performance Monitoring Tools,” gives an overview of some of the performance monitoring tools available from Oracle and third-party vendors and describes how they can help you in investigating performance problems Chapter 7, Performance Engineering Starts at the Design... 291 Hardware Considerations 294 Tuning Considerations 294 Oracle Tuning 294 Server OS Tuning 295 Enhancements 296 Parallel Query Option 297 Oracle Parallel Server Option 297 Hardware Enhancements 298 Performance Verification 300 xi Oracle Performance Tuning & Optimization xii What To Test in the RDBMS 301 What... appropriate to start this book by reviewing the Oracle architecture Following the architectural overview, I give an overview of the products and services Oracle provides This introduction will leave you with an appreciation of the diversity of products Oracle offers Oracle Corporation is one of the world’s largest vendors of software for managing information Oracle has over 12,000 employees with offices... smallest pieces that make up an Oracle database; they are physically stored on disk Although the data block in most systems is 2K (2,048 bytes), you can change this size for efficiency depending on your application or operating system Sizing the data block is described in detail in Chapter 10, Performance Enhancements.” The Oracle Instance The Oracle instance consists of the Oracle processes and shared... database The instance is made up of the user processes, the Oracle background processes, and the shared memory used by these processes (see Figure 1.4) The following sections look at the various pieces that make up the Oracle instance, starting with the shared memory and continuing with the various Oracle processes The Oracle Memory Structure Oracle uses shared memory for several purposes, including... the Design Stage,” explains the holistic approach to performance engineering Performance should be engineered into every aspect of the system, from hardware selection and network configuration to database design and application development xxv Oracle Performance Tuning & Optimization Part II, “Tuning the Server,” focuses on tuning the RDBMS server The performance of the system depends on a number of factors . Products 13
Oracle RDBMS Products 13
Oracle Workgroup Server 15
Personal Oracle for Windows 16
Oracle Development Tools 16
Oracle Applications 17
Oracle Services. 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