ORACLG
Oracle
Press14
Oracle
Database
12c
Release
2
Performance
Tuning Tips
and
Techniques
Richard
J.
Niemiec
Mc Graw Hill EducationNew York
Chicago
San Francisco Athens London Madrid MexicoCity
Acknowledgments
xxixIntroduction xxxvii
IntroductiontoOracle Database 12c R1 &R2New Features
(DBA
andDeveloper)
1Oracle Database12cR1 (12.1.0.1) 5 IncreasedSize Limitto32K forVARCHAR2 and NVARCHAR2 5
Partial Indexes 5 InvisibleColumns 6
Multiple
Indexesonthe Same Column List 7Fetch Firstx Rows 8
Pluggable
Databases(PDBs) 9Oracle Database Cloud Service(Databaseas a Service) 11 PDBLevel: MEMORYJJMITand MEMORY_MINIMUM (12cR2) 17
Change Compression
at ImportTime 18Adaptive Query Optimization
18PGA_AGGREGATE_LIMIT 19 ConcurrentExecution for UNION/UNION ALL 20 Invoker
Rights
FunctionCan Be Results Cached 20 New DBMS_UTILITY.EXPAND_SQL_TEXT 20 Default for Columns Based onSequence
20Multiple
SSD Devicesfor Smart Flash Cache 20ConcurrentCost-Based
Optimizer
StatisticsGathering
21Enhanced
System
Statistics 21Resource
Manager
forRunaway Queries
22Automatic Data
Optimization
(ADO) 22 Global Index Maintenance:Drop
andTruncate PartitionOperations
23ASM Disk
Scrubbing
23Xli
Oracle Database 12c Release2 PerformanceTuning Tips
andTechniques
Online
Capability
Improvements 23Data Guard Improvements 24
RMAN
Improvements
24Oracle Database 12cR1 (12.1.0.2) 25
In-Memory
Database 25Advanced Index
Compression
28 AutomaticBig
TableCaching
28FDA
Support
for Container Databases 28Full Database
Caching
28JSON
Support
28FlPS 140 Parameterfor
Encryption
28PDB Subset
Cloning
29Rapid
HomeProvisioning—Creating
"GoldImages" 29Oracle Database 12cR2 (12.2) 29
Application Development
29Enhanced Featuresto ReduceCostsand Issuesfor
Migration
toOracle 30Availability
30BigData 33
Compression and
Archiving
33Oracle RAC and Grid Infrastructure 34
Security
34New
Background
Processes in 12c 34 Exadata—New with Exadata X6! 35 VersionComparison
Chart 36 New Features Review 41 References 42 2 Basic IndexPrinciples (Beginner Developer
andBeginner
DBA) 43Basic Index
Concepts
45Invisible Indexes 47
Multiple Types
of Indexeson the SameColumn(s) 50Concatenated Indexes 53
Suppressing
Indexes 54UsingtheNOTEQUAL
Operators:
<>, != 55Using
IS NULLor IS NOT NULL 55Using
LIKE 57Using
Functions 58Comparing
Mismatched DataTypes
58Selectivity
59The
Clustering
Factor 59The
Binary Height
60Additional Details
Concerning
BLEVEL and IndexHeight
62Using Histograms
64Fast Full Scans 65
Contents
xiii
Types
of Indexes 67 B-Tree Indexes 68Bitmap
Indexes 69 Hash Indexes 71Index-Organized
Tables 72Reverse
Key
Indexes 73Function-Based Indexes 73 Partitioned Indexes 74
New 12cR2 Featuresfor Partitioned Indexes 78
BitmapJoin Indexes 78
FastIndex
Rebuilding
79Rebuilding
Indexes Online 79Tips
Review 80References 82
3
Pluggable
Databases,
DiskImplementation
Methodology,
andASM(DBA) ... 83Pluggable
Databases (New in Oracle 12c) 85CDB or PDB Created
Objects
86Creating
aPDB: Many Waysto Do It 87Great
Pluggable
Database Commands 88ALTERSYSTEM While in aPDB and Other NiceCommands 92
Using In-Memory(IM) with
Pluggable
Databases 93 Other12cR2 FeatureswithPluggable
Databases 93 SubsetStandby
(New in Oracle 12cR2) 94Disk
Arrays
94UseDisk
Arrays
toImprove
PerformanceandAvailability
94 HowMany
DisksDo You Need? 95What Are Some of the RAID Levels Available? 95
The Newer RAID 5 96
Solid-State Disks 97
ASM
Storage Management (Striping/Mirroring)
97Setup
and Maintenance of the TraditionalFilesystem
98WhatIsthe Cost? 98
Storing
Data and Index Files inSeparate
Locations 99Avoiding
I/O Disk Contention 99The12c HeatMapandAutomatic DataOptimization(ADO) 101
12c I/O Performance
Tracking
Views(Outliers) 102 OracleBigfileTablespaces
103ASM Introduction 104
Communication Across IT Roles 105
ASM Instances 106
ASM Initialization Parameters 107 ASM Installation in 12c 107
Srvctl Enhancements 115
xiv
Oracle Database 12c Release 2 PerformanceTuning
Tips
andTechniques
ASM Rebalance Enhancements 121 ASM FastMirrorResync 123 ASM Filter Driver 124 ASMand
Privileges
132 ASMandMultipathing
136BigfileandASM
137Avoiding
Disk Contentionby Using
Partitions 137Getting
More Information AboutPartitions 139Other
Types
ofPartitioning
140 Partitioned Indexes (Local) 143 Partial Indexes 143Global Index Maintenance:
Drop
and Truncate PartitionOperations
146Other
Partitioning Options
146Index
Partitioning
149Exporting
Partitions 150Eliminating
Fragmentation(Only
IfNeeded—Careful!) 150Using
the CorrectExtent Size 151Avoiding
Chaining
by Setting
PCTFREECorrectly
151Using
AutomaticSegment Space Management
(ASSM) 152Increasing
theLog
FileSizeand LOG_CHECKPOINTJNTERVAL forSpeed
153Determining
IfRedoLog
File Size IsaProblem 154Determining
the Size of YourLog
Files andCheckpoint
Interval 155Other
Helpful
RedoLog
Commands 155Storing Multiple
Control Files onDifferent Disks and Controllers 157 Other Disk I/OPrecautionsandTips 157Issuesto Considerinthe
Planning
Stages
158Tips
Review 159References 161
4
Tuning
the Database with Initialization Parameters (DBA) 163When
Upgrading
toOracle Database12c 165Using
SEC_CASE_SENSITIVE_LOGON 166Crucial Memory InitializationParametersfor Performance 166
PDB Level: MEMORY_LIMIT and MEMORY_MINlMUM 170
In-Memory
Database (INMEMORY_SIZE) 170Changing
the Initialization Parameters Withouta Restart 176Modifying
an Initialization Parameteratthe PDB Level 180Insight
into the Initialization Parameters from Oracle Utilities 181Viewing
the Initialization Parameters withEnterprise Manager
181IncreasingPerformance
by
Tuningthe DB_CACHE_SIZE 182Using V$DB_CACHE_ADVICEin
Tuning
DB_CACHE_SIZE 185Monitoring
theV$SQLAREA
ViewtoFind Bad Queries 186Setting
DB_BLOCK_SIZEtoReflectthe SizeofYour Data Reads 189Contents XV
Tuning
theSHARED_POOL_SIZEforOptimal
Performance 191Using
Stored Procedures forOptimal
Use of the SharedSQL
Area 191Setting
the SHARED_POOL_SIZEHigh Enough
toFully
UsetheDB_CACHE_SIZE 193
Keeping
the DataDictionary
CacheObjects
Cached 193Keeping
theLibrary
Cache Reload Ratio at 0and theHit RatioAbove95Percent 195
Using
AvailableMemorytoDetermineIf the SHARED_POOL_SIZEIsSet
Correctly
197Using
theX$KSMSPTableto GetaDetailed Lookatthe Shared Pool 198 PointstoRemember About Cache Size 199 Waits Relatedto Initialization Parameters 200Using
OracleMultiple
BufferPools 201Pools Relatedto DB_CACHE_SIZE and
Allocating Memory
for Data 201Modifying
the LRUAlgorithm
202Pools RelatedtoSHARED_POOL_SIZEand
Allocating Memory
for Statements 202Tuning
PGA_AGGREGATE_TARGETand PGA_AGGREGATE_LIMIT 203Modifying
the Size of Your SGAtoAvoidPaging
andSwapping
204Understanding
the OracleOptimizer 204How
Optimization
Looksatthe Data 204Creating
Enough
Dispatchers
205Have
Enough
Open
Cursors(OPEN_CURSORS) 206Don't Let Your DDL Statements Fail (DDL_LOCK_TIMEOUT) 206
Two
Important
Exadata Initialization Parameters(ExadataOnly)
207Top
25Initialization Parameters 207Initialization Parametersoverthe Years 210
Finding
Undocumented Initialization Parameters 210Understanding
theTypical
Server 211Modeling
aTypical
Server 212Sizing
the OracleApplications
Database 213Tips
Review 218References 220 5
Tuning
withEnterprise
Manager
Cloud Control (DBA andDeveloper)
221 OracleEnterpriseManager
Basics andAccessing
OEM via Oracle Cloud 223Starting
with AllTargets
and OtherGroupings
227Monitoring
andTuningUsing
theOEMPerformanceMenu 229Performance Tab:Top
Activity
229Performance Tab:SQL
|
SQL PerformanceAnalyzer
230Performance Tab: Real-TimeADDM 233
Performance Tab:SQL
|
AccessAdvisor 237Performance Tab:
Manage Optimizer
Statistics 237Performance Tab:AWR
|
AWR Administration 238 Performance Tab: ASHAnalytics
241XVI Oracle Database 12c Release2 Performance
Tuning
Tips
andTechniques
Monitoring
andTuning Using
theOEMAdministration Menu 241 Database AdministrationTab:Storage|Tablespaces
242DatabaseAdministrationTab:
In-Memory
Central andInitialization Parameters 244
Database Administration Tab: All Initialization Parameters 244
Database Administration Tab: Resource
Manager
(ConsumerGroups)
246Monitoring
andTuningUsing
theOEM DatabaseorCluster DatabaseMenu 247Database Tab:Job
Activity
247 Cluster Database Tab:Configuration!
DatabaseTopology
248Monitoring
theHosts 248Monitoring
theApplication
Servers and WebApplications
250Real
Application Testing
(DatabaseReplay)
252Summary
253Tips
Review 253References 254
6
Using
EXPLAIN, TRACE,
andSQL
PlanManagement (Developer
andDBA)
255 TheOracleSQLTRACEUtility
256Simple Steps
for SQLTRACE with aSimple Query
257The Sections ofaTRACE
Output
262Digging
into theTKPROFOutput
263Using
DBMS_MONITOR 266Setting
Trace Basedon Session IDand Serial Number 267Setting
Trace Basedon Client Identifier 267Setting
Traceforthe ServiceName/Module Name/Action Name 268 EnabledTracing
Views 269 TRCSESSMultiple
Trace Files into One File 269Using
EXPLAIN PLAN Alone 271AnAdditional EXPLAIN
Example
foraSimple Query
273EXPLAIN PLAN—Read It
Top
to BottomorBottom toTop?
274Tracing/Explaining
Problem QueriesinDeveloper
Products 279Important
Columns inthe PLAN_TABLETable 280Using
DBMS_XPLAN 282Initialization Parameters for Undocumented TRACE 283
Using
Stored Outlines 284Dropping
Stored Outlines 285Using
SQL PlanManagement(SPM) and SPMExample
285SPM Terms 286
Using
SPM 287Using
Fixed SQL Plan Baselines 291Dropping
a Plan 292Converting
from Stored OutlinestoSQLPlanManagement
292Adaptive
Plans(12cNewFeature)and SPM 294TipsReview 301
Contents
xvii
7 Basic HintSyntax (Developer
and DBA) 305Top Hints Used 307
Use Hints
Sparingly
308Fixthe
Design
First 308AvailableHintsand
Groupings
309ExecutionPath 309
AccessMethods 310
Query
Transformation Hints 310Join
Operations
311Parallel Execution 311
Other Hints 311
Specifying
a Hint 312Specifying Multiple
Hints 313When
Using
an Alias, Hint theAlias,
Notthe Table 314TheHints 314
The Oracle Demo
Sample
HRSchema 314 The FIRST_ROWSHint 315 The ALL_ROWS Hint 316The FULL Hint 316
The INDEX Hint 317
The NOJNDEX Hint 319
The INDEXJOIN Hint 320
TheINDEX_COMBINEHint 320
TheINDEX_ASC Hint 321
TheINDEX_DESCHint 322
TheINDEX_FFS Hint 322 The ORDERED Hint 323 The LEADING Hint 324 The NO_EXPAND Hint 325 TheDRIVING_SITE Hint 325 TheUSE_MERGEHint 326
The USE_NL Hint 327
The USE_HASH Hint 328
TheQB_NAME Hint 329
ThePUSH_SUBQ Hint 330
The PARALLEL Hint 331
TheNO_PARALLEL Hint 332
ThePARALLELJNDEX Hint 333
TheAPPEND Hint 333 TheNOAPPEND Hint 334 The CACHE Hint 334 The NOCACHE Hint 335 TheRESULT_CACHEHint 335 The CURSOR_SHARING_EXACTHint 336
wiii
Oracle Database 12c Release2 PerformanceTuning Tips
andTechniques
The INMEMORY and NOJNMEMORYandOther IM Hints 337
The USEJNVISIBLEJNDEXESHint 338
The CONTAINERS Hint 339
The
WITH_PLSQL
Hint 339Some Miscellaneous Hints and Notes 339
Undocumented Hints 341
Using
HintswithViews 342Noteson HintsandStored Outlines (or SQL Plan Baselines) 343
Why
Isn'tMy
HintWorking?
343 HintsataGlance 343Tips
Review 345References 347
8
Query
Tuning (Developer
andBeginner
DBA) 349 Which Queries Do I Tune?Querying V$SQLAREA
andV$SQL
Views 351Selecting
fromtheV$SQLAREAView toFind the WorstQueries 351Selecting
from theV$SQLViewto Find the WorstQueries 353 Oracle 12c ViewsforLocating
Resource-Intensive Sessions andQueries
354Selecting
fromV$SESSMETRICto Find Current Resource-Intensive Sessions .. . 354Viewing
AvailableAWRSnapshots
355Selecting
from theDBA_HIST_SQLSTATViewto Find the WorstQueries 355 When Should I UseanIndex? 356Selecting
Query
TextfromtheDBA_HIST_SQLTEXTView 357Selecting Query
EXPLAIN PLAN from the DBA_HIST_SQL_PLANView 358 What If IForget
the Index? 359Creating
an Index 360Invisible Index 360
Checking
the Indexon aTable 360 Isthe ColumnProperly
Indexed? 361WhatIfI Createa Bad Index? 362
Exercising
CautionWhenDropping
anIndex 364Indexing
the Columns Used in the SELECT and WHERE 365Using
the Fast Full Scan 367Making
theQuery"Magically"
Faster 368Caching
aTablein Memory 369Using
the Result Cache 371Choosing
Among
Multiple
Indexes(Use theMostSelective) 372TheIndex
Merge
373Indexes That Can Get
Suppressed
375 Function-Based Indexes 377 Virtual Columns 378 The "Curious" OR 379Using
the EXISTS Function and the NestedSubquery
380ThatTable Is
Actually
aView! 381Contents XIX
Tuning Changes
inOracle Database 12c 382Oracle12c
Adaptive
Query Optimization 383Adaptive
Statistics 389Oracle 12c
Changes
in StatisticsGathering
andTwo NewHistograms
394Oracle12c
Changes
in SQLPlanManagement
395Oracle AutomaticSQL
Tuning
397Ensuring
theTuning
User Has Accesstothe APIs 398Creating
theTuning
Task 398Making
Sure the Task Can Be Seen in the AdvisorLog
399Executing
theSQL Tuning
Task 399Checking
Status of theTuning
Task 399Displaying
theSQL Tuning
Advisor Report 399Reviewing
theReport Output 400Tuning SQL
StatementsAutomatically Using
SQL TuningAdvisor 402Enabling
Automatic SQLTuning
Advisor 402Configuring
Automatic SQLTuning
Advisor 402Viewing
AutomaticSQLTuning
Results 403Using
SQLPerformanceAnalyzer
(SPA) 407Tips
Review 412 References 414 9 TableJoins
and Other AdvancedTuning
(Advanced
DBAandDeveloper)
... 415Database
Replay (capture/replay)
417Set
Up
Source Database for DatabaseReplay Capture
418Prepare
toCapture
Workload 418Capturethe Workload 418
Preparethe Workload for
Replay
419Processthe Workload for
Replay
420Prepare
toReplay
the Workload 420ExecutetheWorkload
Replay
421SQLPerformance
Analyzer
423Createa SQL
Tuning
Set 423Createan
Analysis
Task 424Execute
Analysis
Task 424Query
SQL PerformanceAnalyzer
Advisor Tasks 425Cancel an
Executing
SQLPerformanceAnalyzer Analysis
Task 425RemoveSQL Performance
Analyzer
Analysis
Task 426Determine ActiveSQL
Tuning
Sets 426RemoveSQL
Tuning
Set 426Drop
SQLTuning
Set 427JoinMethods 427
NESTED LOOPSJoins 428
SORT-MERGEJoins 428 CLUSTER Joins 429 HASH Joins 430
XX Oracle Database 12c Release 2 Performance
Tuning Tips
andTechniques
TableJoinInitialization Parameters 434
SORT-MERGE andHASHJoin Parameters 434 ATwo-Table Join:
Equal-Sized
Tables(Cost-Based) 435 ATwo-Table INDEXEDJoin:Equal-Sized
Tables(Cost-Based) 439Forcing
aSpecific
Join Method 443Eliminating
Join Records (Candidate Rows) in MultitableJoins 445 A Two-TableJoin BetweenaLarge
and Small Table 447Three-TableJoins: Notas Much Fun 450
BitmapJoin Indexes 452
Bitmap
Indexes 452Bitmap
Join Index 454BestUsesforthe
Bitmap
Join Index 455Third-Party
ProductTuning
458Example
1 458Example
2 459Example
3 460TuningDistributed
Queries
462WhenYou Have
Everything
Tuned 464Miscellaneous
Tuning Snippets
464ExternalTables 465
Snapshot
Too Old:Developer Coding
Issue 469Set Eventto
Dump Every
Wait 46914 Hours to 30Seconds with the EXISTS
Operator
471Tuningatthe Block Level (Advanced) 473
Key
Sections ofa BlockDump
476ABrief Look atan Index Block
Dump
483Tuning Using
Simple
MathematicalTechniques
485Traditional Mathematical
Analysis
486Seven-Step Methodology
486DerivingPerformance
Equations
487Pattern
Interpretation
493Mathematical
Techniques
Conclusions 498Tips
Review 499 References 50010
Using
PL/SQL
to Enhance Performance(Developer
andDBA)
503Leveragethe
PL/SQL
Function Result CachetoImprove
Performance(Improved
in 12c) 505DefinePL/SQL
Subprograms
in aSQL
Statement(Newin 12c) 515Reference Sequences
Directly
in PL/SQLExpressions
517Identity
Columns (New in 12c) 519Max Size Increaseto 32K forVARCHAR2,NVARCHAR2, and RAW Data
Types
(Newin 12c) 521 Allow
Binding PL/SQL-Only
DataTypes
toSQLStatements (New in 12c) 522Contents
xxi
Simplify
Loopswith the CONTINUE Statement 525Leverage
Compile-Time
Warnings
toCatchProgramming
Mistakes(Improved
in12c) ... 528IncreasePerformancewith Native
Compilation
530Maximize Performancewiththe
Optimizing Compiler
533UseDBMS_APPLICATION_INFOfor Real-Time
Monitoring
539Log Timing
Information in aDatabase Table 541Reduce PL/SQL
Program
Unit Iterations and IterationTime 544Use ROWID for Iterative
Processing
546StandardizeonDataTypes, IF Statement
Order,
and PLSJNTEGER 548 Ensure theSame DataTypes inComparison Operations
548 OrderIFConditions Based ontheFrequency
of the Condition 550Usethe PLSJNTEGERPL/SQLData
Type
forInteger Operations
551Reduce the Calls toSYSDATE 552
Reduce theUseof the MOD Function 553
Improve
Shared Pool Useby Pinning
PL/SQLObjects
555Pinning
(Caching)
PL/SQLObject
Statements intoMemory
555Pinning
AllPackages
556Identify
PL/SQLObjects
That Needto Be Pinned 557Useand
Modify
DBMS_SHARED_POOLSIZES 557Find
Large Objects
558Get Detailed
Object
Information from DBA_OBJECT_SIZE 558 GetContiguous Space Currently
in the Shared Pool 559 Find InvalidObjects
559 Find DisabledTriggers
561Use
PL/SQL
AssociativeArraysfor FastReference TableLookups
562Find andTunetheSQLWhen
Objects
AreUsed 565ConsiderTime ComponentWhen
Working
with DATE DataTypes
568Use
PL/SQL
to TunePL/SQL
570Understand the
Implications
ofPL/SQLObject
Location 571 UseRollbackSegments
toOpen Large
Cursors 572Active Transaction
Management:
ProcessLarge Quantities
ofData 573Use
Temporary
DatabaseTables for Increased Performance 574LimittheUseof
Dynamic
SQL 574Use
Pipelined
Table FunctionstoBuildComplex
ResultSets 575 Leave ThoseDebugging
Commands Alone! 580The"Look and Feel":Justfor the
Beginners
586PL/SQL
Example
587CreateaProcedure
Example
587Execute the Procedure from
PL/SQL Example
588CreateaFunction
Example
588Execute the GET_CUST_NAME FunctionfromSQL
Example
588Createa
Package Example
588DatabaseTrigger
Example Using
PL/SQL 589Tips
Review 589 References 592XXH Oracle
Database
12c Release2 PerformanceTuning Tips
andTechniques
11 Oracle
Cloud,
Exadata,
Tuning
RAC,
andUsing
Parallel Features 593 The March tothe Cloud (PastandPresent) 596 The Oracle Cloud 599 Exadata Database Machine 609Exadata
Terminology
and the Basics 609Exadata Statistics 610
Exadata
Storage Expansion
RackBriefly
612Smart Scans 614
Flash Cache 614
Storage
Indexes 617Hybrid
ColumnarCompression
618I/O Resource
Management
621Use All Oracle
Security Advantages
with Exadata 622Best Practices 622
Summary:
Exadata =Paradigm
Shift! 623Oracle Database
Appliance
(ODA) 624SuperCluster
Usingthe M7 SPARCChip
624Other OracleHardwaretoConsider 625 Oracle
Big
DataAppliance
X6-2 625ZFS
Storage
Servers 625StorageTek
ModularLibrary System
625Parallel Databases 626
Real
Application
Clusters (RAC) 626Oracle RAC Architecture 627
Internal
Workings
of theOracle RACSystem
629RAC Performance
Tuning
Overview 632RAC Cluster Interconnect Performance 633
Finding
RAC Wait Events—SessionsWaiting
633RAC Wait Events and Interconnect Statistics 635
Cluster Interconnect
Tuning—Hardware
Tier 641BasicConceptsof Parallel Operations 645
Basic
Concepts
ofParallelOperations
645Parallel DMLandDDLStatements and
Operations
647Managing
Parallel Server Resources and Parallel StatementQueuing
648 Parallelism and Partitions 649Inter- and
Intra-operation
Parallelization 649Examples
ofUsing
Inter- andIntra-operations
(PARALLEL and NO_PARALLEL Hints) 650
Creating
Table and IndexExamples
Using
ParallelOperations
652Monitoring
ParallelOperations
viathe V$Views 653Using
EXPLAIN PLAN andAUTOTRACEonParallelOperations
655Using
the SET AUTOTRACE ON/OFF Command 658Contents
xxiii
ParallelLoading
662Optimizing
ParallelOperations
in RAC 664Objectives
of ParallelOperations
664RAC Parallel
Usage
Models 664Parallel InitializationParameters 665
V$Viewsfor
Viewing
ParallelStatistics 665CreateTableAs 665
Parallel Index Builds 665
Performance Considerations and
Summary
666Other Parallel Notes 666 Oracle Documentation Is Online 666
Tips
Review 667 References 668 12 TheV$
Views(Developer
andDBA)
671Creating
andGranting
AccesstoV$Views 673Obtaining
aCountandListing
ofAllV$Views 676Getting
aListing
for theX$Scripts
ThatMakeUp
theV$Views 677Examining
theUnderlying
Objects
That MakeUp
the DBA_Views 678Using
Helpful
V$Scripts
680Basic Database Information 681 Basic Automatic Workload
Repository
(AWR) Information 682 BasicLicensing
Information 683 DatabaseOptions
Installed in Your Database 683Summary
ofMemory
Allocated (V$SGA) 684Querying
V$IM_SEGMENTSAfterSetting
theINMEMORY_SIZE 685Automatic
Memory Management
and MEMORY_TARGET 687Detailed MemoryAllocated(V$SGASTAT) 688
Detailed MemoryAllocated(V$SGASTAT) foraPDBvs. Root CDB 689
Finding spfile.ora/init.ora
SettingsinV$PARAMETER 690Modifying
anInitialization ParameteratPDBLevel 691Determining
IfData Is inMemory
(V$SYSSTAT &V$SYSMETRIC) 692Determining Memory
fortheDataDictionary
(V$ROWCACHE) 693Determining Memory
forthe Shared SQLandPL/SQL
(V$LIBRARYCACHE) 694Querying
V$CONTAINERSandV$PDBSfor Container Information 696Querying
V$CONTAINERSWhenUsing Pluggable
Databases 696Querying
V$PDBSforPluggable
Database Information 697Using
the Result Cache 698Identifying
PL/SQLObjects
That Needto BeKept (Pinned) 700Finding
ProblemQueriesby Monitoring
V$SESSION_LONGOPS 701Finding
ProblemQueriesby Querying V$SQLAREA
703Finding
Out What Users AreDoing
and Which ResourcesThey
AreUsing
704Finding
Out WhichObjects
aUser IsAccessing
705XXIV Oracle Database 12c Release2 Performance
Tuning Tips
andTechniques
Using
Indexes 706Identifying Locking
Issues 708Killing
the Problem Session 710Finding
UserswithMultiple
Sessions 711Querying
forCurrentProfiles 712Finding
DiskI/O Issues 713Checking
forPrivileges
and Roles 715Wait Events V$ Views 718
Some of the
Major
V$ ViewCategories
721Tips
Review 728 References 730 13 The X$ Tables and InternalsTopics
(Advanced
DBA) 731Introducing
theX$Tables 732Misconceptions
About theX$Tables 734Granting
AccesstoViewthe X$ Tables 734Creating
V$Views and X$ Tables in 12c 735TheX$Tables
Comprising
theV$Views 737Obtaining
aListof All the X$Tables in 12c 738Obtaining
aListof All theX$ Indexes in12c 740Using
Hints with X$Tables and Indexes 741Monitoring Space
Allocationsinthe Shared Pool 742Creating
Queriesto Monitorthe Shared Pool 743ORA-04031 Errors 744
Large
AllocationsCausing
Contention 745Shared Pool
Fragmentation
745Low Free Memory in Shared and Java Pools 747
Library
CacheMemory Use 747High
Numberof Hard Parses 750Mutex/LatchWaitsand/or
Sleeps
751MiscellaneousX$ TableNotes 752
Obtaining
Information About RedoLog
Files 753Setting
Initialization Parameters 753Case 1 754
Case 2 755
Case3 755
Case4 755
Case 5 755
Exploring
Buffer Cache/Data Block Details 757Buffer Statuses 758
Segments
Occupying
Block Buffers 760Hot Data Blocks and the Causes of Latch Contention and Wait Events 761
Obtaining
Database- andInstance-Specific
Information 766Contents XXV Oracle Internals
Topics
768Traces 768 DBMS_TRACE
Package
772 Events 773Dumps
774 ORADEBUG 775 trcsessUtility
777Reading
theTraceFile 778Wait Information and
Response
Time 781 RecursiveCalls 782 Module Info 782 Commit 783Unmap
783 Bind Variables 783 Errors 784Some Common X$Table
Groups
784 SomeCommonX$Table andNon-V$ Fixed View Associations 801CommonX$Table Joins 803
X$Table
Naming
Conventions(MyFavorite Section of This Book!) 805 X$TableNaming
Conventionswith CONJD,and INMEMORY 812 FutureVersion Impactin 12cR2 813Tips
Review 813References 814
Using Statspack
and
the AWRReport
toTuneWaits, Latches,
andMutexes ... 815What's New in 12cR2(12.2)
Statspack
and theAWRReport
817Installing
Statspack
818Security
of the PERFSTAT Account 818Post-Installation 819
Gathering
Statistics 820Running
the StatisticsReport
822The Automatic Workload
Repository
(AWR) and the AWRReport
824Manually Managing
the AWR 825AWRAutomated
Snapshots
826AWR
Snapshot Reports
826Run theAWRReportin Oracle
Enterprise Manager
Cloud Control 828Interpretingthe
Statspack
andAWR ReportOutput
831The Header Information and Cache Sizes 832
The Load Profile 833
Instance
Efficiency
835Shared Pool Statistics 838
Top
Wait Events 838Oracle
Bugs
851 The Life ofanOracle ShadowProcess 852XXvi
Oracle Database 12c Release2 PerformanceTuning Tips
andTechniques
RAC Wait Events and Interconnect Statistics 852
Top
SQLStatements 853 InstanceActivity
Statistics 856Tablespace
and File I/O Statistics 861SegmentStatistics 864
Additional
Memory
Statistics 865 UNDO Statistics 871 Latch andMutex Statistics 872Tuning
andViewing
atthe Block Level (Advanced) 883Dictionary
andLibrary
Cache Statistics 886SGA
Memory
Statistics 888Nondefault Initialization Parameters 889
Top
15Things
toLook forin AWRReport
andStatspack
Output
890Managing
theStatspack
Data 892Upgrading Statspack
892Deinstalling Statspack
893Quick
Notesonthe New ADDMReport
893Scripts
in 12cR2 898Tips
Review 900References 902
15
Performing
aQuick
System
Review(DBA)
905Total Performance Index (TPI) 906
Education Performance Index (EPI) 907
System
Performance Index(SPI) 909Memory Performance Index (MPI) 912 Top25 "MemoryAbuser"StatementsTuned 912
Top
10"Memory
Abusers"asa Percentof AllStatements 914Buffer Cache HitRatio 914
Dictionary
CacheHit Ratio 916Library
Cache Hit Ratio 91 7PGA
Memory
Sort Ratio 918Percentage
of Data Buffers Still Free 919Using
the Result CacheEffectively
920Pinning/Caching
Objects
921 Disk PerformanceIndex(DPI) 922Top
25 "Disk-Read Abuser" Statements Tuned 922Top
10 Disk-Read AbusersasPercentage
of AllStatements 923Tables/Indexes
Separated
orUsing
ASM 925Mission-Critical Table
Management
925Key
Oracle FilesSeparated
926Automatic Undo
Management
926Contents XXVII Total Performance Index(TPI) 930
Overall
System
ReviewExample
930Rating System
931Example System
ReviewRating Categories
931Items
Requiring
Immediate Action 933Other Items
Requiring
Action 934System
Information List 934Memory-Related
Values 934Disk-Related Values 935 CPU-Related Values 935
Backup-
andRecovery-Related
Information 936Naming
Conventionsand/or Standards and Security InformationQuestions
.. . 937DBA
Knowledge
Rating
937Other ItemstoConsiderin Your TPI and
System
Review 938Tips
Review 939References 940
16 Monitor the
System Using
Unix Utilities(DBA)
941 Unix/Linux Utilities 942Using
thesarCommandtoMonitor CPUUsage
943sar -u(Checkfor CPU
Bogged
Down) 943Thesar-d Command(Find I/O Problems) 944
Thesar-b Command(Checkthe BufferCache) 947
Thesar-q Command(Checkthe RunQueue and
Swap Queue Lengths)
948Usingthesarand vmstatCommandstoMonitor
Paging/Swapping
948Using
sar-pto Report PagingActivities 949Using
sar -wto Report SwappingandSwitching
Activities 949Using
sar -rto ReportFreeMemory and FreeSwap 950Using
sar-gtoReport Paging
Activities 950Using
sar-wpgrtoReport
onMemory
Resources 951Finding
theWorst Useron theSystem Using
thetopCommand 954Monitoring
Tools 955Using
theuptime
CommandtoMonitor CPU Load 955Using
thempstatCommandtoIdentify
CPU Bottlenecks 956Combining
ps with Selected V$ Views 957CPU/Memory Monitoring
Tool (TaskManager)
onWindows 959Using
the iostat CommandtoIdentify
Disk I/O Bottlenecks 959Using
iostat-d for Disk Drives sd15, sd16, sd17, and sd18 960Using
iostat-D 960Using
iostat-x 960Combining
iostat-xwithLogic
ina ShellScript
961Using
theipcs
CommandtoDetermine SharedMemory
962XXVlii
Oracle Database 12c Release2 PerformanceTuning Tips
andTechniques
Monitoring
Disk FreeSpace
964The dt Command 965 TheduCommand 966
Monitoring
Network Performance with netstat 966Modifying
theConfiguration
Information File 967Other Factors That Affect Performance 967 Other Sources toImprove Performance 969
Tips
Review 969References 970 A
Key
Initialization Parameters (DBA) 971Obsoleted/Desupported
Initialization Parameters 972Deprecated
Initialization Parameters 973Top
25 Initialization Parameters 974Top
20 Initialization Parameters NottoForget
977Top 13 Undocumented Initialization Parameters (As I See It) 978
Bonus 11 Undocumented Initialization Parameters 981
Listing
of Documented Initialization Parameters(V$PARAMETER)
982Listing
of Undocumented Initialization Parameters(X$KSPPI/X$KSPPCV)
1009Additional Oracle
Applications
Notes 1009Concurrent
Managers
1009Applications—Finding Module-Specific
Patches 1011Diagnostics
DataCollection: EBSAnalyzers
1011WebServer
Tuning
1013Timeouts 1014
Database Initialization ParameterSizing 1016
Top
10 Reasons NottoWriteaBook 1017Tips
Review 1017References 1018
B The
V$
Views (DBAandDeveloper)
1019CreationofV$ and GV$ Views and X$Tables 1020
A Listof Oracle 12c(12.2.0.0.1) GV$Views 1021
A ListofOracle 12c(12.2.0.0.1) V$Views 1021
Oracle 12c
Scripts
for theX$Tables Used to CreatetheV$Views 1029 C TheX$
Tables (DBA) 1039 Oracle 12cR2 X$Tables Orderedby
Name 1040Oracle 12cR2 X$ Indexes 1048
Oracle 12cR2V$Views Cross-ReferencedtotheX$Tables 1048