Professional Documents
Culture Documents
Oracle Database
Performance
Management Best
Practices
Copyright 2014 Oracle and/or its affiliates. All rights reserved. |
Agenda
Introduction
Oracle Database Performance Tuning Fundamentals
Top Challenges
Database Management
78%
48%
46%
39%
Key Takeaway:
Improve & Ensure Higher Quality of Service
20142013
Oracle and/or
its affiliates.
All rights
reserved. |
Source: From Database Clouds to Copyright
Big Data:
IOUG
Survey
On Database
Manageability
Continuous Innovation
Agenda
Introduction
Oracle Database Performance Tuning Fundamentals
Database time is total time spent by user processes either actively working or actively
waiting in a database call.
Fundamental Concepts
Active Session =
Session currently spending time in a database call
Database Time (DB Time) =
Total time session spent in all database calls
Browse
Books
Read Reviews
For One Book
Add to Cart
Checkout
TIME
10
11
Agenda
Introduction
Oracle Database Performance Tuning Fundamentals
12
Will optimizer_index_cost_adj
improving my sequential reads
Find a
problematic
metric
Did it work?
Implement a
possible Fix
The trial and error method can consume more than 50% of the DBA time
Copyright 2014 Oracle and/or its affiliates. All rights reserved. |
13
Built-in, self-diagnostics
Diagnostics
Find
engine:
Automatic Database
Diagnostics Monitor (ADDM)
(Diagnostics Pack)
Tuning
Fix
SQL
Performance
Validate
Analyzer
(SPA)
Validates
tuning activities
(Real Application Testing)
14
Tuning
SQL Performance
Analyzer (SPA)
Diagnostics
AWR
ADDM
ADDM
Rich feature-set provides comprehensive support for diagnosing problems: System Session, Targeted or Transient, Hung or
slow moving databases, etc. Built into the Oracle kernel and highly optimized (already part of the SGA)
17
18
Helps answers questions like has this SQL gotten slower over time?
Performance
Range
Time
19
Browse and
Read
Reviews
Add
item to cart
Checkout using
one-click
DB Time
Time
SID
Module
SQL ID
State
Event
7:38:26
213
Book by author
qa324jffritcf
WAITING
7:42:35
213
Get review id
aferv5desfzs5
CPU
7:50:59
213
Add to cart
hk32pekfcbdfr
WAITING
7:52:33
213
One click
abngldf95f4de
WAITING
20
PL/SQL
Resources
Identifiers
Attributes
SQL
Session
Attributes
PL/SQL
ASH
Session
Identifiers
SQL ID
PL/SQL
Wait Class
Instance
Consumer
Group
Plan Hash
Top Level
PL/SQL
Wait Event
Services
Module
Operation
Object
User Session
Action
OpCode
Blocking Session
Parallel Process
Client
Program
Trans. ID
Resources
Session Type
21
22
23
24
24
25
26
27
IO / CPU
Issues
Eliminate Performance
Bottlenecks
High
Load
SQL
Automatic Workload
Repository Snapshots
Self-Diagnostic
Engine
RAC
Issues
Lower IT Management
Costs
Performance &
Management
Advisors
Real-time performance and historic analysis with Automatic Database Diagnostic Monitor
Resolve performance issues faster with drill-down root-cause analysis
28
29
Automatic / Manual
Compare
Period ADDM
Real-Time
ADDM
Enhanced
Real-Time
ADDM
Proactively detect
& diagnose
transient highimpact problems
Built inside the DB
Automatically runs
every 3 seconds
30
Performance
Actual
Baseline
time
31
Regressed SQL
AWR Snapshot
Period 1
I/O Bound
AWR Snapshot
Period 2
Compare
Period ADDM
Analysis Report
Undersized SGA
Effects: regressed SQL, reach resource limits (CPU, I/O, memory, interconnect)
32
STEP 2:
STEP 3:
33
34
Real-Time ADDMArchitecture
EM Agent
Deadlocks
Enhanced
Real-Time
Hangs
ADDM
Diagnostic Connection
JDBC Connection
Latches
Database
ADDM
Analysis
Makes a lightweight connection without acquiring additional locks and resources, bypassing the
SQL layer through the agent
35
36
Triggering Conditions
#
Rule
Condition
High Load
Average active sessions greater than 3 times the number of CPU cores
I/O bound
CPU bound
Active sessions greater than 10% of total load and CPU utilization great
than 50%
Over-allocated
memory
Interconnect bound
Session Limit
Process Limit
Hung Session
Deadlock Detected
37
AWR
Enterprise Manager ASH: Transient / Targeted Performance Analysis
ADDM: Proactive Performance Management and Diagnosis
The above toolset helps identify the potential problems and recommends appropriate
solutions
For SQL related issues, ADDM recommends SQL Tuning Advisors
38
Tuning
39
Stale/Missing statistics
Incomplete statistics
Changing statistics
RESOURCES
Resource &
Contention Issues
APPLICATIONS
Data fragmentation
Application Issues
40
SQL Profiling
Statistics Analysis
Adopt Alternative
Execution Plan
Administrator
SQL Tuning
Advisor
Comprehensive
SQL Tuning
Recommendations
41
Estimation errors occur due to data skews and correlations, complex filters and joins
Doesnt require any change to the SQL text
42
submit
create
Optimizer
(Tuning Mode)
SQL
Profile
SQL Tuning
Advisor
After
output
submit
Optimizer
(Normal Mode)
Database
Users
Well-Tuned
Plan
43
Evaluate
Recommendations
Implement
Workload
DBA
DBA
Generate
Recommendations
one hour
DBA
ADDM
AWR
Invoke Advisor
44
Custom
Apps
SQL Analysis
Automatic
implement
Report
Well-tuned SQL
Manually
implement
45
Workload
Generate
Recommendations
Choose Candidate
SQL
SQL Tuning
Candidates
one week
Its Automatic!
AWR
DBA
46
47
Automatic Tuning
Optimizer
B*-tree indexes
Bit-map indexes
Partitions (11g +)
MV and MV Logs
DBA
Partition Advisor:
Range Partition
Interval Partition
Hash Partition
List Partition
48
DB 11.2
10000
40X
Run Time (seconds)
Partition Advisor
analyses large
workloads 40x faster
than before
1000
20X
100
2X
10
1
1
DB 12.1
3
4
5
6
7
8
SQL Workload Size (in thousands)
10
49
Recommends indexes, partitions (hash and interval only) materialized views, and
materialized view logs to create and/or drop for faster performance
Simultaneously considers
index solutions
materialized view solutions
combinations of both
50
51
52
53
54
55
56
57
58
59
Challenge:
Solution:
Benefit:
Allows DBAs to look into complex
composite DB operations for
analysis and tuning purposes
60
PL/SQL procedures/functions
62
SQL Performance
Analyzer (SPA)
65
SPA Motivation
Businesses need to adapt to changes to stay competitive, compliant and evolve
SQL performance regressions: #1 cause of poor system performance.
DB upgrades, schema, optimizer statistics refresh
Current testing landscape and limitations
Expensive capture, partial workload, non-production optimizer context, binds
Large workloads (100Ks SQL stmts are common)
Manual and time consuming testing and regression tuning
No end-to-end testing solution
Test In Production is not too uncommon
66
SPA Overview
Helps users predict the impact of system changes
on SQL workload response time
Low overhead capture of SQL workload to SQL
Tuning Set (STS) on production system
SQL Workload
STS
Compare
SQL Performance
Analysis Report
67
SPA handles trials in a manner that does not change database data
Hence can be used for testing in production/standby environments
68
69
SPA Report
3
2
1
4
70
71
SPA Challenges
Running SPA on:
Test
Database
Production
Database
Requires separate HW
72
Optimal Trial
Mode, no DML
execute
Controlled
ChangeAware
Optimized
Change-Aware
Pre-selected
STS and
default SPA
settings
Context-aware
change testing
Production
Database
DBA
73
Identifies subset
SQL workload with
plan changes first
Test-executes only
SQLs with plan
changes
Minimizes use of
production
resources
dramatically up
to 10x reduction
Multiple executions
disabled
No full DML
(execute Select
part of workload)
74
75
76
77
78
Agenda
Introduction
Oracle Database Performance Tuning Fundamentals
79
Tuning
SQL Performance
Analyzer (SPA)
80
Diagnostics
Database Home Page gives a quick high level overview of current status
Database found to be running high load (Active Sessions)
ADDM has already detected some performance issues (5 findings)
Copyright 2014 Oracle and/or its affiliates. All rights reserved. |
82
For further investigation, look at the DB Perf. Page and Click on the Big Stuff
DB Perf. Page shows significant resource being utilized on CPU and User I/O
Clicking on the snapshot icon will take us to the ADDM Home Page for that time
Copyright 2014 Oracle and/or its affiliates. All rights reserved. |
83
84
85
Tuning
87
88
89
90
SQL Performance
Analyzer (SPA)
92
Step 3 Validate
93
Step 3 Validate
Take the Guess Work Out!
94
Tuning
SQL Performance
Analyzer (SPA)
Summary
96
Conclusion: Find-Fix-Validate
Get
MORE databases
MORE uptime
97
98
99
AWR
Use AWR Warehouse for longer retention period:
Adaptive thresholds:
The significance level thresholds give users a way to specify alerting in terms of "how
unusual" rather than "how much
Performance tuning metrics:
Use DB Time, CPU Time IO time , not just Elapsed time for performance tuning
DB Time encompasses multiple metrics and provides better insight into the performance of
the system
Copyright 2014 Oracle and/or its affiliates. All rights reserved. |
We can change the Top N SQL or sessions to display in Top Activity. Here is how to do it
$emctl set property [sysman_pwd <sysman_pwd>] -name oracle.sysman.db.ashPurgeSize -value <value>
Real-Time ADDM
Diagnostic connection
In this mode, Real-Time ADDM performs a latch-less connection to the database.
This mode is intended for extreme hang situations when a normal JDBC connection is not
possible.
Precise, actionable recommendations
Provides cluster-wide analysis for RAC
SQL Monitoring
Use Real-time SQL Monitoring to Understand SQL Execution
SQL Details Active Report
Shows whats happening inside SQL execution
Automatically monitors long running SQL
Shows the statistics and resources consumed at each step of the plan.
Shows actual cardinality at each step, helps resolve problems with poor cardinality estimates
SQL Monitoring
Use Active Reports where available: SQL details, SQL Monitor, SPA , ASH, ADDM
Composite Active Report
Allows the user to navigate from one active report to another without connecting to the database
Examples: Performance Hub, SQL Details, Session Details and SQL Monitor List
Performance Hub
Provides a new consolidated view of all performance data for a given time range
DB 12c update
In addition to the composite active reports -- there is now also an active report for SQL Tuning and Automatic Realtime ADDM
The SPA and SQL Monitor Details active reports, which were introduced in 11g, have also been enhanced
For example, the following SQL*Plus script shows you how to generate a Real-time PerfHub Active Report:
SQL>set pages 0
SQL>linesize 32767
SQL>trimspool on
SQL>trim on
SQL>long 1000000
SQL>longchunksize 10000000
SQL>spool perfhub_active.html
SQL>select dbms_perf.report_perfhub(is_realtime=>1,type=>'active') from dual;
The resulting file perfhub_active.html should be edited to remove the header (first line in the file) and the last line (spool off).
SQL Tuning
Use Automatic Tuning Advisor to tune SQL, one of the most underutilized feature by customers
Automatically captures high-load SQL
Automatically tunes SQL without changing application by creating SQL Profiles (If auto
implement is enabled)
Automatically runs during maintenance window
Set task parameters to 1-2 yrs (default 30) for historical tuning information
Validate recommendations from the SQL Tuning Advisor (SQL Profiles, Index recommendations )
Use case: Reactive, SQL performance is suboptimal, invoke SQL Tuning Advisor on high load
or business critical SQL
Pros:
A SQL Profile contains auxiliary information that
corrects the cardinality estimated in a suboptimal Plan.
10
New Features
AWR Warehouse
EM Express
In Memory Advisor
Adaptive Query Optimization
AWR Warehouse
Finance
Supply
Chain
CRM
120%
120%
120%
90%
90%
90%
60%
60%
60%
30%
30%
30%
0%
0%
0%
EM Express
Integrated Install
Small Footprint
Comprehensive
Administration
Disk: 20 MB
Storage management
Security management
No extra MW components
100% of UI rendering
performed in browser
Advanced performance
diagnostics and tuning
Configuration management
10
11
12
In-Memory Central
14
15
Features
Assist with IM Column Store size selection
Recommend tables, partitions and sub-partitions for a given IM Column Store
size
16
Features
Recommendation based on cost/benefit calculations
Cost: Estimated memory size with various compression options
Benefit: Estimated DB time reduction of processing analytic workload
Report
Vary IM Column Store size to receive specific loading plan
Generate DDL script with all the tables/partitions/sub-partitions recommended
Top SQL benefits from given configuration
17
Future
Recommend reconfiguration of existing In-Memory Column Store
Suggest objects to evict
RAC advice
In-Memory Column Store configuration can vary by instance
18
19
20
21
22
Join : Changes join method from Nested Loops to Hash Join, and vice versa, based on cardinality.
Parallel Distribution : Changes data distribution method among parallel processes from Hybrid Hash to
Broadcast, based on cardinality.
23
Even when enabled, factors like predicate complexity, existing base statistics and
total execution time expected determines whether to gather dynamics statistics or not.
24
In contrast to adaptive plans, automatic reoptimization changes a plan on subsequent executions after
the initial execution.
Statistics feedback : When SQL statement is executed (with statistics feedback monitoring enabled) for the first
time, optimizer compares its original cardinality estimates to the actual cardinalities observed during execution
and, if estimates differ significantly from actual cardinalities, it stores the correct estimates for subsequent use.
After the first execution, the optimizer disables monitoring for statistics feedback.
25
Performance feedback : The parallel degree chosen by the optimizer is compared to the parallel degree
computed base on the actual performance statistics (e.g. CPU-time) gathered during the
initial execution of the statement. If the two values vary significantly then the statement is marked for
reoptimization and the initial execution performance statistics are stored as feedback to help compute a
more appropriate degree of parallelism for subsequent executions.
26
SQL plan directives, created automatically as a result of Automatic Reoptimzation, can direct the optimizer to
use dynamic statistics to obtain more accurate cardinality estimate.
Created whenever there is a mismatch between optimizer's cardinality estimates and the actual number of
rows returned after execution.
Created on query expressions, not at statement or object level.
Copyright 2014 Oracle and/or its affiliates. All rights reserved. |
27
Resources
References
2 Day DBA :
http://docs.oracle.com/cd/E16655_01/server.121/e17643/toc.htm
2 Day + Performance Tuning Guide:
http://docs.oracle.com/cd/E16655_01/server.121/e17635/toc.htm
Oracle Database 12c - EM Express Performance Hub:
http://www.oracle.com/technetwork/database/manageability/emx-perfhub-1970118.html
Oracle Database 12c - EM Express Active Reports:
http://www.oracle.com/technetwork/database/manageability/emx-activerep-1970119.html
SQL Performance Analyzer Active Report:
http://www.oracle.com/technetwork/database/manageability/sqlpa-094776.html
Database Manageability and Real Application Testing:
http://www.oracle.com/technetwork/database/manageability/index.html