Professional Documents
Culture Documents
1
Designing and Tuning: Tips and Tricks
NOT
Designing for Oracle
2
Scaling
Some Possible Definitions
Continuous Innovation
3
Database Performance Basics
Schemas and SQL Statements
Scaling
What is it?
n Linear
o Unlimited
p Maximum
q Vertical
r Horizontal
s Unprecedented
t Ultimate
u Predictable
v Diagonal
4
Scalability Quiz
Label the axes ?
80
70
60
50
40
30
20
10
0
1 2 3 4
Scaling
Some Possible Definitions
5
What Prevents Scaling
With respect to CPUs
• Scaling is severely impacted when the following
scenarios arise
• Hardware resources are operating beyond their practical
maximum capacity for work
• Software serialization takes place
• Application e.g. Row lock contention
6
Scaling the Database
In reality
7
Database Performance Basics
Sessions & Cursors(This slide is over 10 Years old!)
400
350
300
250
200
Users
150
100
50
0
Logon Hard Soft Parsing Optimal
Logoff Parsing
EXACT
• Poor SQL
• Poor Access Paths
• Excessive resource usage (CPU, I/O)
• Poor connection management
• High numbers of connections can cause problems
• Use connection pooling/concentration in the middle-tier
• Use of Shared Servers is often just a band-aid
8
Common Configuration Issues
Tuning Oracle
9
Oracle Tuning Methods: A History
• Prehistoric (v5)
• Debug code
• Dark Ages (v6)
• Counters/Ratios
• BSTAT/ESTAT
• SQL*Trace
• Renaissance (v7/v8)
• Introduction of Wait Event instrumentation
• Move from counters to timers
• STATSPACK
• Modernity (v10)
• DB Time Tuning – Tuning using fundamental notion of time spent in database
• Multiple scoping levels
• Always on, non-intrusive
• Built into infrastructure: instrumentation, ASH, AWR, ADDM, EM
• “Time is money”
10
<Insert Picture Here>
11
A Single Session
Single session with Database Black Box server
Fundamental Concepts
12
Multiple Sessions
DB Time = Sum of DB Time Over All Sessions
User 2
User 3
User n
TIME
t
= time spent in database
13
Visualizing DB Time
User 1
User 2
User 3
User n
t0 t1
4
3
2
1
EM Performance Page
14
Where to find DB Time?
• V$SYS_TIME_MODEL, V$SESS_TIME_MODEL
• STAT_NAME = ‘DB time’
• V$SYSMETRIC_HISTORY
• “Database Time Per Second”, “CPU Usage Per Sec”
• 10g units = centi-secs/sec (100xAvg. Active Sessions)
• 11g new metric “Average Active Sessions”
• V$SQL
• ELAPSED_TIME and CPU_TIME
• Wait class times:
APPLICATION, CONCURRENCY, CLUSTER, USER_IO
• V$ACTIVE_SESSION_HISTORY
15
Active Session History (ASH)
• In-memory: V$ACTIVE_SESSION_HISTORY
• Sampling interval = 1 second
• On-disk: DBA_HIST_ACTIVE_SESS_HISTORY
• Sampling interval = 10 second
DB time is area
under curve ∆t = 1 sec
DB Time
t0 time t1
16
Estimating DB Time with ASH
17
Where is DB Time used?
• ADDM
• ASH report
Techniques:
The DB Time Method
18
The DB Time Method: Short Course
Determine where
or database
time isjust
spent,
askand reduce it!
ADDM
19
Investigate DB Time Distribution
• System scope:
• Resource limits – is problem outside the DB?
• Application scope:
• Service, module, action
• Resource contention (e.g. latches)
• SQLID, rowsource
• Session scope:
• Long running SQL
• Resource contention (e.g. enqueues)
DB time
20
Identify Potential Solutions
• SQL issues
• SQL Tuning Advisor => Indexes, SQL profile
• Re-write SQL
• Design issues
• Access Advisor => Indexes, physical layout
• System issues
• Initialization parameters
• Add resources
Modify System
21
The DB Time Method: Advantages
Method Summary
22
<Insert Picture Here>
Tools:
ADDM
Enterprise Manager
Reports
23
Best Practice: Use ADDM
• Variably scoped:
• Host to instance to SQL and even database block
• Scoped to database for RAC (new in 11g)
24
25
Best Practice: EM Real-time Interface
26
27
Conclusions
28
Time for Your Questions
29