Oracle Database 12c
Oracle Database
Performance Management:
Theory and Practice
Mughees A. Minhas
VP, Product Management
Oracle Corp.
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
2
Safe Harbor Statement
The following is intended to outline our general product direction. It is intended for
information purposes only, and may not be incorporated into any contract. It is not a
commitment to deliver any material, code, or functionality, and should not be relied upon
in making purchasing decisions. The development, release, and timing of any features or
functionality described for Oracle’s products remains at the sole discretion of Oracle.
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
3
<Insert Picture Here>
Historical Perspective
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Brief History of Oracle Diagnostics Instrumentation
• Prehistoric (V5)
– Debug Code
• Dark Ages, (V6)
– Counters/ ratios , BSTAT/ESTAT
• Renaissance (V7)
– Introduction of wait events ,
– Moving from counters to timers
• Modernity (V10)
– DB Time, ASH, AWR, ADDM, EM
• Post-modernity (V11 and V12)
– ASH Analytics, Real Time ADDM, RealTime SQL Monitoring , Active Reports,
SPA Quick Check, Performance Hub
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
9
<Insert Picture Here>
Key Concepts
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
What is Database Time (DB Time)?
• Total time in database calls by foreground sessions
• Includes CPU time, IO time and non-idle wait time
• DB Time <> response time
• New metric for Oracle performance analysis
Database time is total time spent by user processes either actively working or
actively waiting in a database call.
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
12
System Variables and DB Time
• More users
– => More calls
• => DB time increases
• Larger transactions
– => Longer calls
• => DB time increases
DB time increases as system load increases.
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
System Performance and DB Time
• IO performance degrades
– => IO time increases
• => DB time increases
• Application performance degrades
– => Wait time increases
• => DB time increases
DB time increases when performance degrades.
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Quiz
Question: What happens to DB Time when
performance improves?
Answer: DB Time decreases
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Quiz
Question: On a four CPU system, for one hour
elapsed time, what is the maximum amount of CPU
time that can be accumulated?
Answer: Four hours of CPU time maximum.
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Quiz
Question: On a four CPU system, for one hour elapsed time, what is
the maximum amount of DB Time that can be accumulated?
Hint: How many sessions can wait in a queue?
Answer: Number of ‘sessions’ * elapsed time
The maximum number of sessions that are on CPU or in a non-idle wait
is the init.ora parameter ‘sessions’. If ‘sessions’ is 300 then:
300 * 1 hour = 300 hours of DB Time
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Fundamental Concepts
Active Session =
Session currently spending time in a database call
Database Time (DB Time) =
Total time session spent in all database calls
Average Activity of the Session (% Activity) =
The ratio of time active to total wall-clock time
Browse
Books
Read Reviews
For One Book
Add to Cart
Checkout
TIME
= time spent in database
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
18
Multiple Sessions
DB Time = Sum of DB Time Over All Sessions
Avg. Active Sessions = Sum of Avg. Activity Over All Sessions
=
Total Database Time
Wall-Clock (Elapsed) Time
At time t we have 2 active sessions
User 1
User 2
User 3
User n
= time spent in database
t
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
TIME
Visualizing DB Time
Total Database Time
Avg. Active Sessions =
Wall Clock (Elapsed) Time
User 1
User 2
User 3
User n
t0
t1
4
3
2
1
TIME
Active Sessions over time
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
DB Time Theory to Practice: EM Performance page
• Active Sessions by wait class over time
• Colored area = Amount of DB time;
• To find root cause of problem: “Click on the Big Stuff” -- CBS Method
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
21
CPU Run-queue and DB Time
Recorded wait time
Recorded wait time
User 1
Run-queue
Db file sequential read
Actual wait time
Run-queue
On CPU
Db file sequential read
Actual wait time
DB time is inflated when host is CPU-bound
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
On CPU
Quiz: What is the problem with this database?
• All wait times are inflated when CPU is maxed out
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Instrumentation: 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”
– 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
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Active Session History (ASH)
• All ‘Active’ sessions captured every second
– Foregrounds and backgrounds are sampled
– Active foregrounds contribute to DB Time
– Many dimensions captured
• In-memory: V$ACTIVE_SESSION_HISTORY
– Sampling interval = 1 second
• On-disk: DBA_HIST_ACTIVE_SESS_HISTORY
– Sampling interval = 10 second
• ASH is a system-wide record of database activity
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Active Session History (ASH)
Query for Khalid
Husaini Novels
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
db file sequential read
7:42:35
213
Get review id
aferv5desfzs5
CPU
7:50:59
213
Add to cart
hk32pekfcbdfr
WAITING
buffer busy wait
7:52:33
213
One click
abngldf95f4de
WAITING
log file sync
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
29
ASH Math
COUNT(*) = DB Time
GROUP BY ?
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
ASH Math: COUNT(*)=DB Time
• ASH is a big fact table
– Each row represents 1-second of active session time
• V$ACTIVE_SESSION_HISTORY
– COUNT(*) = DB time in seconds
• DBA_HIST_ACTIVE_SESS_HISTORY
– COUNT(*) * 10 = DB time in seconds
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Example: DB Time by SQL ID
select sql_id
, count(*) DBTime
, round(count(*)*100/sum(count(*))
over (), 2) pctload
from v$active_session_history
where sample_time > sysdate - 1/24/60
and session_type <> 'BACKGROUND'
group by sql_id
order by count(*) desc;
SQL_ID
DBTIME PCTLOAD
------------- --------- ------6bmxrabnwwsxd
60 63.83
azzsynmz43nrr
8
8.51
28pb73sbwhmm8
5
5.32
58psyvgau23s2
3
3.19
amrq8hk767tuz
2
2.13
2r5qhb3fb63vm
1
1.06
f3919usqp5wj2
1
1.06
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
User Session Performance Dimensions
SQL
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
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
35
Quiz: Why do Perf AAS Graph and Top Activity don’t look
identical
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
37
Quiz: Why do Perf AAS Graph and Top Activity don’t look
identical
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
38
Performance Tuning Methodology
Proactive Performance Management
Reactive Performance Management
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted
41
Proactive Performance Management: SPA Quick Check
• Helps users predict the impact of routine
system changes on production SQL
workload
SQL Plans + Statistics
SQL Plans + Statistics
• Low overhead capture of SQL workload to
SQL Tuning Set (STS)
• Build different SQL trials (experiments) of
SQL statements performance by test
execution or explain plan
• Day to day use cases integrated with SPA
Quick Check, SQL Plan Baselines, & SQL
Tuning Advisor to form an end-to-end
solution
Pre-change Trial
Post-change Trial
Compare SQL
Performance
Analysis Report
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted
42
Proactive Performance Management
Predict the impact of routine system changes on SQL workload response time
• Optimized
– Optimized for use on prod systems
SPA Quick Check
– Optimal Trial or Explain Plan mode
– Disable multi-executions, full DML execute disabled
• Controlled
Optimal Trial
Mode, no DML
execute
Optimized
Controlled/Sc
oped
Per SQL Time Limits,
Limits testing scope to
private session
– Per SQL time limits
– Testing scoped to private session
Change-Aware
Context-aware
change testing
– Associate with Resource Consumer Group
• Change-Aware
– Context-aware change testing workflows, such as,
– Optimizer gather statistics
– Init.ora parameter changes
Pre-selected
STS and
default SPA
settings
Production
Database
DBA
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted
43
Proactive Performance Management
Predict the impact of system changes on SQL workload response time
3
2
1
5
4
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted
44
Performance Tuning Methodology
Reactive Performance Management
• Analyzing transient performance problems
– ASH Analytics
• Diagnose systemic and significant performance issues
– ADDM
• In-depth SQL performance analysis
– Real-Time SQL Monitoring
• Optimizing top SQL’s with sub-optimal plans
– SQL Tuning Advisor
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted
45
Reactive Performance Management
Identify performance issues using ASH Analytics
– Graphical ASH report for advanced analysis
– Provides visual filtering for recursive drill-downs
– Select any time period for analysis
– Analyze performance across many dimensions
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted
46
Reactive Performance Management
• I am a CDBA and asked to
investigate transient performance
issues reported by one application
owner. I need to diagnose the
cause of these issues and address
them
• AWR report indicates some unusual
issues on the system
– But I don’t get a PDB specific report…
– What to do next?
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted
47
Reactive Performance Management
Analyzing transient performance problems using ASH Analytics
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
48
ASH Analytics identifies User I/O as the problem
Identify SQL’s that are subject to User I/O
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
49
Which Database Performance Diagnostics Tool to Use?
• Automatic Workload Repository – AWR Reports
– Reports about performance and workload data from AWR
• Active Session History – ASH
– Gathers fine-grain data about every active database session
every second
• Automatic Database Diagnostics Monitor - ADDM
– Data Analysis and Problem Identification
– Findings and Advise on how best to resolve bottlenecks
• Real-time SQL and Database Operations Monitoring
– Provides in-depth diagnostics about SQL execution at row
source level
Database Performance Hub provides holistic performance management
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 50
Database Performance Hub
Holistic Performance Management
• Single view of DB performance
– ADDM, SQL Tuning, Real-Time SQL Monitoring,
ASH Analytics
• Switch between ASH analytics,
workload view, ADDM findings
and SQL monitoring seamlessly
• Supports both real-time &
historical mode
• Historical view of SQL Monitoring
reports
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
51
Performance Hub Report
• New interactive report for analyzing AWR data
• Performance Hub report generated from SQL*Plus
– @$ORACLE_HOME/rdbms/admin/perfhubrpt.sql
OR calling dbms_perf.report_perfhub(….)
function
– Single view of DB performance
– ADDM, SQL Tuning, Real-Time SQL Monitoring,
ASH Analytics
• Switch between ASH analytics, workload view,
ADDM findings and SQL monitoring seamlessly
• Supports both real-time & historical mode
• Historical view of SQL Monitoring reports
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
52
Automatic Performance Diagnostics
Continuous Evolution in Database Performance Management
ADDM
• Diagnose persistent
performance issues
• Uses AWR snapshots
• Regular interval
• Automatic / Manual
Compare
Period ADDM
Real-Time
ADDM
• In-depth performance • Hung or extremely
comparison across
slow databases
two periods
• Uses a normal and
• Relies on AWR data
diagnostic mode
connection
• Manual
• Manual
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Enhanced
Real-Time
ADDM
• Proactively detect
& diagnose
transient highimpact problems
• Built inside the DB
• Automatically runs
every 3 seconds
72
Automatic Performance Diagnostics Monitor (ADDM)
Boost Administrator
Productivity
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
Deliver Higher Quality
of Service
• Runs proactively out of the box, reactively when required
• Top-down analysis using Automatic Workload Repository snapshots
• Real-time performance and historic analysis with Automatic Database Diagnostic Monitor
• Resolve performance issues faster with drill-down root-cause analysis
• Classification tree based on Oracle performance tuning expertise
• Performance expert; now a RAC specialist too in Oracle Database 11g
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
73
Proactive Performance Management: ADDM
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
74
Compare Period ADDM
SQL Commonality
Regressed SQL
AWR Snapshot
Period 1
I/O Bound
AWR Snapshot
Period 2
Compare
Period ADDM
Analysis Report
Undersized SGA
• Full ADDM analysis across two AWR snapshot periods
• Detects causes, measure effects, then correlates them
– Causes: workload changes, configuration changes
– Effects: regressed SQL, reach resource limits (CPU, I/O, memory, interconnect)
• Makes actionable recommendations along with quantified impact
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
76
Compare Period ADDM: Method
STEP 1:
• Identify what changed
• DB configurations, workload changes
STEP 2:
Did the Buffer cache get smaller?
• Quantify performance
differences
Why is there
10% new SQL?
• Uses DB Time as basis for measuring performance
STEP 3:
Why did Top SQL impact increased by 45%?
• Identify root cause
Read I/O are up by 55%, why?
• Correlate performance differences with changes
Did a buffer cache reduction cause a read I/O increase?
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
77
Compare Period: Report
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
78
Real-Time ADDM—Architecture
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
• Also attempts to initiate standard JDBC connection
• Data returned by either connection is analyzed by ADDM
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
79
Real-Time ADDM Enhancements
Oracle Database 12c
• Automatic real-time problem detection and analysis
• Database self-monitors for serious performance issues
• Recognize bad performance trends and trigger analysis:
• High CPU, I/O spikes, memory, interconnect, hangs, deadlocks
• Identify a problem before it threatens application performance
• Short duration (5 min spikes) ADDM analysis
• Actionable advice for critical issues
• Richer data set available for analysis
• Reports (analysis and data) stored in AWR for historical analysis
• ADDM, SQL Monitoring reports
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
80
Triggering Conditions
#
Rule
Condition
1
High Load
Average active sessions greater than 3 times the number of CPU cores
2
I/O bound
Impact on active sessions based on single block read performance
3
CPU bound
Active sessions greater than 10% of total load and CPU utilization great
than 50%
4
Over-allocated
memory
Allocation over 95% of physical memory
5
Interconnect bound
Single block interconnect transfer time based
6
Session Limit
Session limit close to 100%
7
Process Limit
Process limit close to 100%
8
Hung Session
Significant number of hung sessions. If this number is greater than 10%
of total sessions
9
Deadlock Detected
Any deadlock detected by hang analyzer
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
81
Find: Performance Diagnostics Summary
Topics Covered
• Database Time
• 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…
Next Steps: Tune the identified SQL problems
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
82
Tuning
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
83
What makes SQL go bad?
Optimizer Issues
Inaccurate statistics
Suboptimal Plans
Optimizer Statistics
•
•
•
•
•
Table Statistics
Column Statistics
Index Statistics
System Statistics
Exadata System
Statistics
CBO
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
84
What makes SQL go bad?
Parallelism Issues
Not parallelized (no scaling to large data)
Improperly parallelized (skews, RAC, etc)
Table
Table
Serial Table Scan
Parallel Servers
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
85
What makes SQL go bad?
Missing Access Structures
• Indexes: B-tree indexes,B-tree cluster indexes, Hash cluster indexes, Global and local indexes,
Reverse key indexes, Bitmap indexes, Function-based indexes, Domain indexes
• Materialized Views
• Materialized View Logs
• Partitioned Tables
B-tree index
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 86
What makes SQL go bad?
Poorly written SQL statements
SELECT * FROM employees
WHERE to_char(salary) = :sal
SELECT * FROM employees
WHERE salary = TO_NUMBER(:sal)
• Convert literal once and not the whole column
SELECT * FROM parts_old
UNION
SELECT * FROM parts_new
SELECT * FROM parts_old
UNION ALL
SELECT * FROM parts_new
• If you know there are no rows in common
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 87
What makes SQL go bad?
Resource and Contention Issues
•
Hardware Resource Contention
•
•
•
•
CPU
memory
I/O
Logical Contention
•
•
row lock contention
block update contention
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 88
What makes SQL go bad?
a. Bind Peeking Issue
Processed_Flag
Y
Y
Y
Y
Full Table Scan
CBO
FTS
Two different optimal plans
99
Index Range Scan
IRS
1
N
Problem: Binds will affect optimality in any subsequent uses of the stored plan
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 89
What makes SQL go bad?
b. Literal Usage Issue
SELECT * FROM jobs WHERE min_salary > 12000;
SELECT * FROM jobs WHERE min_salary > 15000;
SELECT * FROM jobs WHERE min_salary > 10000;
SELECT * FROM …
SELECT * FROM …
SELECT * FROM …
Cursor Sharing
Library Cache
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 90
SQL Performance Issues: Broad Categories
Optimizer
 Stale/Missing statistics
 Upgraded Database: new optimizer
 Incomplete statistics
 Changing statistics
 Improper optimizer configuration
 Rapidly changing data
RESOURCES
Resource &
Contention Issues
APPLICATIONS
 Hardware resource crunch
 Not parallelized (no scaling to large data)
 Contention (row lock contention, block contention)
 Improperly parallelized (partially parallelized, skews)
 Data fragmentation
 Rapidly changing data
 Missing access structures
 Poorly written SQL statements
Application Issues
 Bind-sensitive SQL with bind peeking (Cursor Sharing)
 Literal usage
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
91
Automatic SQL Tuning
Gather Missing or Stale Statistics
Create a SQL Profile
SQL Profiling
Add Missing Access Structures
Statistics Analysis
Modify SQL Constructs
Access Path Analysis
Adopt Alternative
Execution Plan
SQL Restructure Analysis
Alternative Plan Analysis
Parallel Query Analysis
Automatic Tuning Optimizer
Create Parallel SQL Profile
Administrator
SQL Tuning
Advisor
Comprehensive
SQL Tuning
Recommendations
• SQL Tuning Advisor
• Gives suggestions on the various problems identified during the diagnosis phase
• Uses the same CBO but has more time budget to perform comprehensive analysis
• Identifies alternate execution plans using real-time and historical performance data
• Recommends parallel profile if it will improve SQL performance significantly (2x or more)
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
92
What is SQL Profile?
• Contains auxiliary information collected by the ATO for a SQL statement
– Customized optimizer settings
• Based on past execution history (e.g., first_rows vs. all_rows)
– Compensation for missing or stale statistics
– Compensation for errors in optimizer estimates
• Estimation errors occur due to data skews and correlations, complex filters and joins
• Doesn’t require any change to the SQL text
– Ideal for Packaged Apps
• Persistent: Works across shutdowns & upgrades
• Transportable across databases (10.2)
• Force Matching for Literals: This setting may be useful for queries that use only literal values
• SQLTUNE_CATEGORY: Enables you to test a profile in a restricted environment before making it
available to other sessions. Can be enforced at session level or system level, this defaults to system
level
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
93
SQL Profiling Flow
SQL Profiling
submit
create
Optimizer
(Tuning Mode)
SQL
Profile
SQL Tuning
Advisor
After …
output
submit
Optimizer
(Normal Mode)
Database
Users
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Well-Tuned
Plan
94
SQL Tuning in Oracle Database 10g
End-to-End Workflow
Evaluate
Recommendations
Implement
Workload
DBA
DBA
Generate
Recommendations
one hour
DBA
ADDM
AWR
Invoke Advisor
SQL Tuning Advisor
SQL Tuning Candidates
A good end-to-end solution,
but manual intervention required
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
95
Automatic SQL Tuning in Oracle Database 11g/12c
Packaged
Apps
• Complete automation of SQL tuning
Custom
Apps
• Automatically captures high-load SQL
Auto Capture High-Load SQL
Nightly
Automatic SQL Tuning
SQL Profiles
SQL Analysis
• Automatically tunes SQL without
changing application by creating SQL
Profiles
• Automatically implements (optional)
greatly improved SQL plans
• Automatically reports analysis
Automatic
implement
Report
Well-tuned SQL
Manually
implement
• Automatically runs during maintenance
window
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
96
Automatic SQL Tuning in Oracle 11g/12c
Implement
SQL Profiles
Test SQL Profiles
Workload
Generate
Recommendations
Choose Candidate
SQL
SQL Tuning
Candidates
one week
It’s Automatic!
View Reports / Control
Process
AWR
DBA
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
97
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
98
Workload Tuning: SQL Access Advisor
Recommendations
Access Path Analysis
Automatic Tuning
Optimizer
B*-tree indexes
SQL Access Advisor
Bit-map indexes
Partitions (11g +)
MV and MV Logs
DBA
Partition Advisor:
• Range Partition
• Interval Partition
• Hash Partition
• List Partition
• Provides List Partition recommendations for 12c Database
• Analyzes already partitioned tables for further optimization
Significant reduction in analysis time for very large workloads (DB12c)
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
99
SQL Access Advisor: Partition Advisor
Analysis Run Times Oracle Database 11.2 versus 12.1
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
2
3
4
5
6
7
8
SQL Workload Size (in thousands)
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
9
10
100
SQL Access Advisor Features
• Recommends indexes, partitions (hash and interval only) materialized views, and
materialized view logs to create and/or drop for faster performance
• Analyzes entire workload and not just independent SQL statements
• Takes into account impact of new access structures on DML operations
• Considers storage, creation and maintenance costs
• Simultaneously considers
– index solutions
– materialized view solutions
– combinations of both
• Optimizes materialized views for
– maximum query rewrite usage
– fast refresh
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
101
Real-Time SQL Monitoring
Looking Inside SQL Execution
•
•
•
•
Automatically monitors long running SQL
Enabled out-of-the-box with no performance impact
Monitors each SQL execution
Exposes monitoring statistics
– Global execution level
– Plan operation level
– Parallel Execution level
• Guides tuning efforts
• Bind values shown
• SQL level metrics
– CPU, I/O requests, throughput, PGA, temp space
• Graphical explain plan
• I/O statistics for each operation
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
102
Real-Time PL/SQL Monitoring
• PL/SQL execution no longer a “black box”
– Answers questions like “why did my DBMS_STATS job take twice as long this time?”
• Shows global (PL/SQL) and SQL level statistics
• Each SQL called by PL/SQL recursively monitored
• Drill-down to slow SQL for diagnosing unexpected PL/SQL behavior
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
103
SQL Monitoring Use Cases
Big Plans
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
SQL Monitoring Use Cases
Big Plans
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
SQL Monitoring Use Cases
Big Plans
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
SQL Monitoring Use Cases
Expensive Hash Join
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
SQL Monitoring Use Cases
Poor Indexing
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
SQL Monitoring Use Cases
FORCE PARALLEL QUERY PARALLEL 4
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Real-Time Database Monitoring
What’s Really Happening in the Database
Challenge:
Solution:
•
SQL & PL/SQL Monitoring only
monitors a single execution
•
Real-Time Database Operations
Monitoring
•
How does a DBA monitor a
composite operation such as a
batch job?
•
Benefit:
Allows DBAs to look into complex
composite DB operations for
analysis and tuning purposes
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
117
Monitor Complex Database Operations
• Oracle Database 11g: Support for simple DB operations
• SQL statements (e.g., SQL for DSS, batch/report SQL, runaway SQL)
• PL/SQL procedures/functions
• Oracle Database 12c: Support for composite operations
• Session(s) activity between 2 points of time defined by application code / DBA
• For example; SQL*Plus script, batch job, or ETL processing
• At most one DBOP per DB session
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
119
SQL Performance
Analyzer (SPA)
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
12
2
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
SQL plans + stats
Pre-change Trial
SQL plans + stats
Post-change Trial
• Build different SQL trials (experiments) of SQL
statements performance by test execution
• Analyzes performance differences
• Offers fine-grained performance analysis on
individual SQL
Compare
SQL Performance
Analysis Report
• Integrated with STS, SQL Plan Baselines, & SQL
Tuning Advisor to form an end-to-end solution
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
124
When to use SPA?
• SPA can be used with Oracle Database Releases 10.2 , 11g and 12c
– Optimizer statistics refresh
– Validate and implement of tuning recommendations from ATO
– Database parameter changes, schema changes (e.g., add/drop indexes)
– I/O subsystem changes (e.g., ASM, Database Machine)
• SPA handles trials in a manner that does not change database data
– Hence can be used for testing in production/standby environments
• For supported releases, test database upgrades and patch-set releases*
SPA Provides Broad Testing
Coverage
•
•
•
•
Across many releases of Oracle and for upgrades
On test, standby, and production environments
Extended to home-grown scripts, third-party testing tools, etc.
Supports most applications - EBS, SAP, Siebel, home-grown, etc.
*MOS Note: 560977.1
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
125
SPA: Enterprise Manager Interface
•
•
Rich GUI through Enterprise Manager
DBMS_SQLPA package PL/SQL API
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
126
SPA Report
3
2
5
1
4
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
127
SPA Report: Regressed SQL Statements
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
128
Find  Fix  Validate
Tuning
STEP 1 - Find Issues
Diagnostics
STEP 2 - Fix Issues
SQL Performance
Analyzer (SPA)
STEP 3 - Validate Fix
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Summary
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
153
Conclusion: Find-Fix-Validate
Improved Quality Of Service
Manage and Automate
Get
• MORE databases
• MORE uptime
• MORE risk free administration on production
• MORE Quality Of Service
• MORE effort less testing on production
• MORE sleep at night!
• MORE applications support: OLTP, DW, COTS
• MORE weekends off!
• MORE users, larger databases
• MORE mission-critical applications
Become
• MORE proactive and strategic
• MORE important and valuable!
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
154
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
155
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
156
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertisement