Professional Documents
Culture Documents
Guy Harrison,
Executive Director, Information Mgt R&D,
Dell Software Group
@guyharrison
REMINDER
Check in on the
COLLABORATE mobile app
Top 10 Oracle
database tuning tips
Guy Harrison,
Executive Director, Information Mgt
R&D,
Dell Software Group
Introductions
Web:
guyharrison.net
Email: guy.harrison@software.dell.com
Twitter: @guyharrison
But Seriously
The top 10
Be methodical and
empirical
11
12
Application
Result sets
Return codes
SQL
Database Server
Request
Blocks
Return
blocks
Server Memory
Request
Blocks
Return
blocks
IO subsystem
13
Application
Result sets
Return codes
SQL
RDBMS code
Request
Blocks
Return
blocks
Server Memory
Request
Blocks
Return
blocks
IO subsystem
14
15
Measurement
http
://guyharrison.net/OPSGSam
ples/Ch03/timeModelSimple.
sql
16
Database design
Database design
18
19
3NF version
20
Dont go to far!
In this example the designer pulled
address into a separate table and city,
country into another table.
Its correct in theory, but it means that
every time we want an employees
address we have to join three tables.
It would have been better to have just
one table
21
22
Subtypes
Its usually better to put all the data in one table, or have two tables for each subtype
Having a supertype table and two subtype tables means you always have to join
tables
Probably dont
want to do this
23
Denormalization
24
Index Wisely
Indexes
26
last,first,birthyear,id
last,first,BirthYear
last+first name
last name
63
None
0
1459
200 400 600 800 1000 1200 1400 1600
Logical IO
27
SELECT cust_id
FROM sh.customers c
WHERE cust_first_name = 'Connor'
AND cust_last_name = 'Bishop'
AND cust_year_of_birth = 1976;
Index overhead
7
6
14,285
12,727
Number of indexes
Indexes speed up
queries, but make
DML (insert, update,
Delete) slower
16,316
10,719
8,691
6,671
1 (PK only)1,191
0
5,000
10,000
15,000
28
20,000
Index or FTS?
1000
100
Elaspe d Tim e (s )
10
1
0
10
20
30
40
50
60
29
100
Application code
31
Parse overhead
Its easy enough in most programming languages to create a new SQL every time
you execute the query:
32
33
Bind Variables
No Bind variables
200
400
600
Parse Time
34
800
Other
1000
1200
1400
Designing transactions
35
36
40,000
35,000
30,000
25,000
20,000
15,000
10,000
5,000
0
0
20
40
60
80
100
37
120
140
38
Optimize the
optimizer
Cardinality
Estimates
Object Statistics
DB parameters
And config
Optimizer inputs
IO and CPU
Estimates
Remember: Garbage In :
Garbage Out
The optimizer can only do a
good job if statistics are up to
date
40
System Statistics
Cost estimate
Histograms
20,000
18,000
16,000
14,000
12,000
10,000
Number of rows
8,000
6,000
4,000
2,000
0
41
Without a histogram
Number of rows
the estimated
Real number of
rows
42
Optimizer
chooses not to
use an index
With a histogram
Optimizer
estimate is
correct
Optimizer
chooses to use an
index
43
DBMS_STATS
GATHER_INDEX_STATS , GATHER_SCHEMA_STATS,
GATHER_TABLE_STATS
Basic statistics
method_opt
Histograms
method_opt
=>
method_opt
=> 'FOR ALL COLUMNS FOR COLUMNS
(function(column)))'
DBMS_STATS.gather_system_stats (
gathering_mode => 'NOWORKLOAD');
DBMS_STATS.gather_system_stats
(gathering_mode
=> 'INTERVAL',
interval
=> 60);
44
46
Also, V$SQL_PLAN,
V$SQL_PLAN_STATISTICS
Tkprof, session trace
47
48
49
Monitor and
manage contention
Application
Demand for DB
services
51
Apparent
demand at lower
layers is reduced
Types of contention
Locks
Usually locking problems
are due to application
locks (remember
optimistic locking)?
52
Latches and
Mutex
Buffer
contention
user
user
Buffers
53
user
Database
files
Buffers
Buffer
Waits
Read
from
buffers
Read
from
disk
Database
Writer
Write
dirty
blocks
to disk
Database
files
54
Lock/Latch
Possible cause
Buffer busy
55
Optimize memory
to reduce IO
57
Multi-pass
Disk Sort
Single
Pass
Disk Sort
Memory
Sort
Table/Index IO
More Memory
58
Available Memory
CPU Time
Temp Segment IO
Less Memory
Time
59
60
IO Tuning
62
The amount of IO you can support depends on the number of disks you have
Provide enough disks to support the amount of IO you need
even if that means the disks are not filled with data
Magnetics disks can do between 75-150 IO per second (IOPS) do the math!
20
40
60
80
100
IO/ps
63
120
140
160
180
200
70
60
Sparsely populated
Under only moderate load
50
40
30
20
10
0
0
64
65
66
SSD DDR-RAM 15
SSD PCI flash 25
SSD SATA Flash 80
Magnetic Disk
4,000
0
1,000
2,000
67
3,000
4,000
5,000
But not by
the GB
10
12
10
10
2.9
2.3
2.2
8
7.4
1.7
1.3
$$/GB
1
$$/GB
2011
5.3
2013
2012
2014
3.2
0.35 2.9
0.28
2.2
2.3
1.7
0.21
0.1
1.3
0.17
0.35
0.28
0.21
0.17
0.13
0.13
0
2011
2012
2013
2014
2015
HDD
68
2015
MLC SDD
SLC SSD
69
$/IOP
$/GB
Table on SSD
Flash cache
IO
DB File IO
Other
CPU
121
583
2,211
500
1000
70
1500
2000
2500
Table on SSD
72
398
418
71
Flash Cache IO
DB File IO
Other
CPU
Total
4000
3500
Multi-pass
Disk Sort
3000
2500
2000
1500
Single Pass
Disk Sort
1000
500
0
300
250
200
150
100
50
1,637
331
1,681
Log File IO
Other
CPU
SAS based redo log
1,605
500
397
73
1,944
Tune RAC
75
Toad: your
companio
n in the
Big Data
revolution
76
Starter
Configuration
8 Node Cluster
R720- 4 Infrastructure Nodes
R720XD- 4 Data Nodes
Force10- S55
~176TB (disk raw space)
~1.5TB (raw memory)
Mid-Size Configuration
16 Node Cluster
R720- 4 Infrastructure Nodes
R720XD- 12 Data Nodes
Force10- S4810P
Force10- S55
~528TB (disk raw space)
~4.5 TB (raw memory)
Small Enterprise
Configuration
24 Node Cluster
R720- 4 Infrastructure Nodes
R720XD- 20 Data Nodes
~880TB (disk raw space)
~7.5 TB (raw memory)
77
78
Oracle
SQL Server
HANA
SSD database acceleration
Large memory footprints
Thank you.
79
#C15LV