Sie sind auf Seite 1von 135

Workshop

Oracle Database
Performance
Management Best
Practices

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


Agenda
• Introduction
• Oracle Database Performance Tuning Fundamentals
• Find, Fix and Validate: Methodology and Toolset
• Find Fix and Validate: An Example
• Real-World Best Practices & Tips
• New Features and Enhancements (DB 12.1.0.2)

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 4


Downtime resulting from
78% untested changes
Top Challenges
Database Management 48% Use SQL tuning to address
performance issues

Data stores growing by


46% 20%+
?

Handle more than 50 DBs


39% each
Key Takeaway:
Improve & Ensure Higher Quality of Service
Source: From Database Clouds to Copyright
Big Data: © 20142013 IOUG
Oracle and/or Survey
its affiliates. On Database
All rights reserved. | Manageability 5
Continuous Innovation

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 6


Agenda
• Introduction
• Oracle Database Performance Tuning Fundamentals
• Find, Fix and Validate: Methodology and Toolset
• Find Fix and Validate: An Example
• Real-World Best Practices & Tips
• New Features and Enhancements (DB 12.1.0.2)

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 7


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. | 8


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 Read Reviews


Add to Cart Checkout
Books For One Book

= time spent in database TIME

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 9


DB Time Theory to Practice: EM Performance page

• Active Sessions by wait class over time


• Colored area = Amount of DB time , More the DB time , More the Problem
• “Click on the big stuff…”

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 10


ASH Theory to Practice: EM ASH Analytics Page
• Graphical ASH report for advanced
analysis
• Select any time period for analysis
• Analyze performance across many
dimensions
• Provides visual filtering for
recursive drill-downs
• Different visualizations: Stacked
chart or Tree Map
• Collaborate with others using
Active Reports

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 11


Agenda
• Introduction
• Oracle Database Performance Tuning Fundamentals
• Find, Fix and Validate: Methodology and Toolset
• Find Fix and Validate: An Example
• Real-World Best Practices & Tips
• New Features and Enhancements (DB 12.1.0.2)

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 12


Past DB Tuning Process
• Inefficient, Inaccurate, Manual

Find a Implement a
problematic possible Fix
Will optimizer_index_cost_adj metric Default value is 100,
improving my sequential reads… …so let’s set it to 50…

Wait for end-


user
Did it work? feedback Are customers complaining?

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


Future Generation DB Tuning Process
• Effective, Accurate, Automated

Built-in, self-diagnostics Fix


Tuning Automates complex and time
Find
Diagnostics
engine: consuming
Automatic Database task of application tuning
Diagnostics Monitor (ADDM) – (Tuning Pack)
(Diagnostics Pack)

SQL
Performance Validates
Validate
Analyzer tuning activities
(SPA) (Real Application Testing)

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 14


Find  Fix  Validate

STEP 1 - Find Issues STEP 2 - Fix Issues


Diagnostics Tuning

SQL Performance
Analyzer (SPA)

STEP 3 - Validate Fix

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |


Diagnostics

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |


Find-Fix-Validate Methodology and Toolset
Find:
– Gather Data: Performance and workload data capture AWR
• System statistics, wait information, SQL Statistics, etc.
– Data Analysis and Problem Identification
• What types of operations are consuming most time?
• Which resources is the bottleneck? ADDM
• What is the root cause?
• How can problem be remediated?
– If multiple problems identified, which is most critical?
– Which solution will give me most benefit?
– For SQL Related problems, ADDM points recommends running ADDM
SQL Tuning Advisor

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)

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 17


Gathering Data Automatic Workload Repository (AWR)
• Built-in workload and performance statistics repository in the database
• Automatically captures workload data
– Every 60 minutes, or manually, saves data for 8 days by default
• Resides in SYSAUX tablespace
• Space requirements automatically managed
– Old data is automatically purged nightly based on retention interval
• Stores different classes of data:
– BASE STATISTICS e.g., physical reads
– SQL STATISTICS e.g., disk reads (per sql stmt)
– METRICS e.g., physical reads / sec
– SQL Monitor Report Data
– ACTIVE SESSION HISTORY (ASH)

• Support for Exadata and In-Memory Database statistics

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 18


Active Session History (ASH)
• Samples active sessions every one second into memory (v$active_session_history)
• Helps answers questions like “has this SQL gotten slower over time?”
• Direct access to kernel structures
Performance
• One of ten samples flushed to AWR at every snapshot
Range
• Data captured includes:
– SID
– SQL ID
– Program, Module, Action
– Wait event#
– Object, File, Block
– actual wait time (if captured while waiting)
*
Time

Enables targeted performance analysis of transient problems

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 19


Active Session History (ASH)

Query for Khalid Browse and Add Checkout using


Husaini Novels Read item to cart ‘one-click’
Reviews

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. | 20


User Session Performance Dimensions

SQL PL/SQL Resources Identifiers Attributes


SQL
Consumer
SQL ID PL/SQL Wait Class Instance
Group

Top Level
Session PL/SQL
Plan Hash
PL/SQL
Wait Event Services Module
Attributes

ASH Operation Object User Session Action

OpCode Blocking Session Parallel Process Client

Session
Resources
Identifiers Program Trans. ID

Session Type

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 21


Case Study 1: Slow Application Response Problem - Correlating
AWR & ASH Data
Application users are complaining of poor performance. How do we diagnose
the issue and resolve it?

• Several factors can impact SQL Response time


– Increased or unusual load on system
– Hardware Issues
– Runaway queries consuming system resources
– Changes in execution plans
– Missing or stale object statistics
• Need a mechanism to quickly analyze in-memory performance data

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 22


Application Response Time Analysis - AWR
2 Wait event enq TX contributes to this DB time
AWR top 5 section shows the Wait Class which
contributes most to DB wait time

1 Wait class application constitutes 55% of DB time

Foreground Wait Class section in AWR to see


distribution of DB waits over Waits classes
3 Identify segments that contribute to this wait

Objects involved in TX row lock contention can


be identified in Segment Statistics section of
AWR
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 23
Analyze ASH: Correlate the findings from AWR

1 Analyze ASH Report for the period of increase of


applications waits, it shows the same as AWR

24
2 Identify the module that suffered from this type of
contention from the top service/module
section

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 24


Identify the Impacted Sessions and SQL’s
3 Identify the top sessions impacted from this type
of contention/wait from the Top sessions
section

Identify the SQL’s associated with this type of


4 contention/wait from the Top SQL section

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 25


Identify the Blockers and the Objects Causing the Contention
Identify the blocking sessions associated with this
5 wait event from the Top Blocking Sessions
section

Nail down the objects that is subject to this wait


6 from the Top DB Objects Section

So how do you resolve this issue?

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 26


Case Study 2: Understanding I/O Bottle Neck with ASH Analytics
Identify SQL’s that are subject to User I/O
Understand
Identify the Object subject tothe
FullPlan Operation
Table Scan that causes the I/O

• Graphical ASH report for advanced analysis • Different visualizations: Stacked chart or Tree Map
• Provides visual filtering for recursive drill-downs • Collaborate with others using Active Reports
• Select any time period for analysis
• Analyze performance across many dimensions

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 27


Automatic Performance Diagnostics Monitor (ADDM)
IO / CPU Boost Administrator
Issues Productivity
Eliminate Performance
High
Load Bottlenecks
SQL
Lower IT Management
Costs
RAC
Automatic Workload Issues Performance & Deliver Higher Quality
Self-Diagnostic
Repository Snapshots Management of Service
Engine
Advisors
• 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. | 28


Proactive Performance Management: ADDM

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 29


Automatic Performance Diagnostics
Continuous Evolution in Database Performance Management

Compare Real-Time Enhanced


ADDM Period ADDM ADDM Real-Time
ADDM
• Diagnose persistent • In-depth performance • Hung or extremely • Proactively detect
performance issues comparison across slow databases & diagnose
• Uses AWR snapshots two periods • Uses a normal and transient high-
• Regular interval • Relies on AWR data diagnostic mode impact problems
• Automatic / Manual • Manual connection • Built inside the DB
• Manual • Automatically runs
every 3 seconds

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 30


Comparative Performance Analysis with AWR Baselines
and Reports
• Automatic creation and management of
reference baselines
Performance • Compare Period ADDM: Enables performance
comparison of two periods with AWR Reports
Actual • Makes analysis of workload variations and
performance diagnosis easier
• Moving window baseline created out-of-the-box
• Enables proactive monitoring with adaptive
thresholds
Baseline
• Baseline is key for performance tuning to
– Set alert thresholds
– Monitor performance
– Compare performance variations
time

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 31


Compare Period ADDM
SQL Commonality

AWR Snapshot Regressed SQL


Period 1
I/O Bound

Undersized SGA
AWR Snapshot Compare Analysis Report
Period 2 Period ADDM

• 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. | 32


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: How come 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?


33
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Compare Period: Report

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 34


Real-Time ADDM—Architecture
EM Agent
Deadlocks

Diagnostic Connection Enhanced


Real-Time
Hangs
ADDM
JDBC Connection Latches

ADDM
Database 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. | 35


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. | 36


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 Allocation over 95% of physical memory
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. | 37


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. | 38


Tuning

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 39


SQL Performance Issues: Broad Categories
Optimizer
 Stale/Missing statistics  Upgraded Database: new optimizer
 Incomplete statistics  Changing statistics
 Improper optimizer configuration  Rapidly changing data

RESOURCES
 Hardware resource crunch  Not parallelized (no scaling to large data)
Resource &
Contention Issues  Contention (row lock contention, block contention)  Improperly parallelized (partially parallelized, skews)
 Data fragmentation  Rapidly changing data

APPLICATIONS
 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. | 40


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
SQL Restructure Analysis Execution Plan

Alternative Plan Analysis Create Parallel SQL Profile


SQL Tuning Administrator
Parallel Query Analysis Advisor

Comprehensive
Automatic Tuning Optimizer
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. | 41


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. | 42


SQL Profiling Flow
SQL Profiling

submit create
Optimizer
(Tuning Mode)

SQL Tuning SQL


Advisor Profile

After …

submit output
Optimizer
(Normal Mode)
Well-Tuned
Database Plan
Users

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 43


SQL Tuning in Oracle Database 10g
End-to-End Workflow
Evaluate
Implement Recommendations

Workload DBA DBA


Generate
Recommendations

one hour
DBA

ADDM Invoke Advisor


SQL Tuning Advisor
AWR SQL Tuning Candidates

A good end-to-end solution,


but manual intervention required

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 44


Automatic SQL Tuning in Oracle Database 11g/12c

Packaged Custom
• Complete automation of SQL tuning
Apps Apps
• Automatically captures high-load SQL
Auto Capture High-Load SQL • Automatically tunes SQL without
Nightly changing application by creating SQL
Automatic SQL Tuning Profiles
SQL Profiles SQL Analysis
• Automatically implements (optional)
greatly improved SQL plans
Automatic • Automatically reports analysis
implement Report
Manually
• Automatically runs during maintenance
implement window
Well-tuned SQL

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 45


Automatic SQL Tuning in Oracle 11g/12c

Implement Test SQL Profiles


SQL Profiles

Workload
Generate
Recommendations

Choose Candidate
SQL
SQL Tuning
one week Candidates
It’s Automatic!

View Reports / Control


AWR Process
DBA

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 46


Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 47
Workload Tuning: SQL Access Advisor
Recommendations

Automatic Tuning B*-tree indexes


Access Path Analysis
Optimizer

SQL Access Advisor Bit-map indexes

Partitions (11g +)

MV and MV Logs

DBA

Partition Advisor:
• Range Partition
• Interval Partition • Provides List Partition recommendations for 12c Database
• Hash Partition • Analyzes already partitioned tables for further optimization
• List Partition

Significant reduction in analysis time for very large workloads (DB12c)

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 48


SQL Access Advisor: Partition Advisor
Analysis Run Times Oracle Database 11.2 versus 12.1
Partition Advisor 10000

analyses large 40X

Run Time (seconds)


1000
workloads 40x faster 20X
than before
100
2X
10

DB 11.2
1
1 2 3 4 5 6 7 8 9 10
DB 12.1 SQL Workload Size (in thousands)

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 49


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. | 50


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. | 51


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. | 52
Real-Time SQL Monitoring: Case Study 1

My simple query is taking longer than before. What could have gone
wrong?

• SQL Performance Problems


– Statistics
– Resources
– Application issues
– Parallelism
– Initialization parameters

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 53


Real-Time SQL Monitoring
SQL with count and Group by

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 54


Real-Time SQL Monitoring
SQL with count and Group by

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 55


Real-Time SQL Monitoring
PGA Size increased

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 56


Real-Time SQL Monitoring: Case Study 2

I enabled parallel query, yet this query is taking so long. How do we


approach this problem?

• Parallel Downgrades
– Uncontrolled parallel execution
– Parallel Server availability
– Object level settings
– Session level settings

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 57


Real-Time SQL Monitoring
Parallel Tab

• Parallel Coordinator busy for the entire duration !!


Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 58
Real-Time SQL Monitoring
Enabled Parallel DML

• Parallel Slaves busy for the entire duration !!!


Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 59
Real-Time Database Monitoring
What’s Really Happening in the Database

Challenge: Solution:

• SQL & PL/SQL Monitoring only • Real-Time Database Operations


monitors a single execution Monitoring
• How does a DBA monitor a • Benefit:
composite operation such as a Allows DBAs to look into complex
batch job? composite DB operations for
analysis and tuning purposes

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 60


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. | 62


SQL Performance
Analyzer (SPA)

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 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

SQL Performance Analyzer (SPA)


 Proactively detects ALL SQL regressions, BEFORE actual change is deployed
 Integrated comprehensive solution for end-to-end SQL workload testing

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 66


SPA Overview
• Helps users predict the impact of system changes SQL Workload
on SQL workload response time STS

• Low overhead capture of SQL workload to SQL


Tuning Set (STS) on production system SQL plans + stats SQL plans + stats
Pre-change Trial Post-change Trial
• Build different SQL trials (experiments) of SQL
statements performance by test execution
• Analyzes performance differences Compare
SQL Performance
• Offers fine-grained performance analysis on Analysis Report
individual SQL
• 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. | 67


When to use SPA?
• SPA supports testing in 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*

• Across many releases of Oracle and for upgrades


SPA Provides Broad Testing • On test, standby, and production environments
Coverage • 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. | 68
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. | 69


SPA Report

3
2 5

1
4

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 70


SPA Report: Regressed SQL Statements

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 71


SPA Challenges

Running SPA on:

Test Production
Test System: Safe but… Database Database Production System: Easier but…

• Requires separate HW • Could be resource intensive and


• Data in test system should be impact production performance
same as production • Changes needs to be manually
• Lengthy, error-prone task scoped to private session
• Could take a long time to finish
DBA
• No resource control by default

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 72


SPA Quick Check

• Optimized for use on prod systems SPA Quick Check


Optimized • Optimal Trial or Explain Plan mode
• Disable multi-executions, full DML execute disabled

Per SQL Time Limits,


Optimal Trial
Limits testing scope to
Mode, no DML Controlled/S
private session
execute Optimized coped

• Per SQL time limits


Controlled • Testing scoped to private session
• Associate with Resource Consumer Group Change-Aware Context-aware
change testing

Production
Database
Change- • Context-aware change testing workflows, such as,
• Optimizer gather statistics
Pre-selected
STS and
default SPA

Aware • Init.ora parameter changes settings


DBA

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 73


SPA Quick Check
Optimized

Minimizes use of
Identifies subset Test-executes only production No full DML
Multiple executions (execute Select
SQL workload with SQLs with plan resources disabled
plan changes first changes dramatically – up part of workload)
to 10x reduction

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 74


SPA Quick Check
Controlled

Per-SQL time limit – protects from runaway SQL

Resource throttling - Associate with Resource


Consumer Group

Testing scope limited to private session

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 75


SPA Quick Check
Change-aware

Change-aware: Knows what change is being


tested

In-line with routine DBA tasks such as statistics


gathering, init.ora parameter changes

Intelligently limits impact to private test session

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 76


SPA Quick Check

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 77


SPA Quick Check

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 78


Agenda
• Introduction
• Oracle Database Performance Tuning Fundamentals
• Find, Fix and Validate: Methodology and Toolset
• Find Fix and Validate: An Example
• Real-World Best Practices & Tips
• New Features and Enhancements (DB 12.1.0.2)

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 79


Find Fix and Validate: An Example

STEP 1 - Find Issues STEP 2 - Fix Issues


Diagnostics Tuning

SQL Performance
Analyzer (SPA)

STEP 3 - Validate Fix

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 80


Diagnostics

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |


Step 1 – The Find
• ADDM automatically detects performance bottlenecks

• 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


Step 1 – The Find
• Average Active Sessions

• 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
Step 1 – The Find
• ADDM Home Page

• ADDM Home Page: Database activity gives quick performance overview


• Looking at the ADDM performance analysis, SQL statements are impacting the system
significantly
• Let’s drill down on the Top SQL Findings
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 84
Step 1 – The Find
Automatic Diagnosis and Recommendations

• 91.2% of the impact is from the SQL statements in the report


• Performance diagnostics data provided for SQL causing high DB resource usage

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 85


Tuning

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |


Step 2 – The Fix
SQL Tuning Advisor

• Run the problematic performing statements through Tuning Advisor


• We will automatically capture the problematic statement
• Top SQL statements are automatically captured in AWR
• Seamless integration between Diagnostics and Tuning

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 87


Step 2 – The Fix
Comprehensive Recommendations

• Comprehensive analysis and multiple alternatives to improve performance


• SQL Profiles can be implemented transparently & non-intrusively to tune SQL statements

• As an example, let’s gather statistics in pending mode…


Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 88
Step 2 – The Fix
Set Publish to False for Scoped Change Testing

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 89


Step 2 – The Fix
Gather Optimizer Statistics

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 90


SQL Performance
Analyzer (SPA)

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |


Validate with SPA Quick Check

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 92


Step 3 – Validate
Optimizer Statistics Refresh Validation

DB Home Page -> Performance -> SPA Link

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 93


Step 3 – Validate
Take the Guess Work Out!

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 94


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. | 96


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. | 97


Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 98
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 99
Real-World Best Practices & Tips

1
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
AWR
• Use AWR Warehouse for longer retention period:
– Allows long term analysis
– Zero overhead and impact on production
• Global AWR reports:
– Use Global AWR reports for RAC
– Configured using $OH/rdbms/admin/awrgrpt.sql
• 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. | 2


Tips: Configuring EM to display Top N Activity
By default, EM is configured to display Top 10 items in the ASH Analytics Page

More than 10 SQL More than 10 sessions

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>


restart the OMS
Default value is 10 , you can set this to 20 or 30 depending on the memory available for the OMS server.
Setting to higher values would require higher memory and hence not recommended.

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 3


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

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 4


SQL Monitoring
Use Real-time SQL Monitoring to Understand SQL Execution
SQL Details Active Report
– Shows what’s 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

Exposes monitoring statistics


– Plan operation level
– Parallel Execution level
– I/O, CPU, memory, network
– Exadata Smart Scans

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 5


SQL Monitoring
Use Active Reports where available: SQL details, SQL Monitor, SPA , ASH, ADDM
• Composite Active Report
– Single HTML file that embeds a set of correlated active reports
– 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
– The Performance Hub can also be saved as a Composite Active Report
• Real Time Performance Hub, Historical Performance Hub, Real-time Performance Hub (RAC)
DB 12c update
• In addition to the composite active reports -- there is now also an active report for SQL Tuning and Automatic Real-
time ADDM
• The SPA and SQL Monitor Details active reports, which were introduced in 11g, have also been enhanced

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 6


Tips: How to generate Active report without EM
• SQL Details Active Report : Use dbms_perf.report_session() function
• SQL Monitor Active Report: Use dbms_sqltune.report_sql_monitor_list() function
• SQL Performance Analyzer Active Report: Use dbms_sqlpa.report_analysis_task() function
• Performance Hub Active Report: Use dbms_perf.report_perfhub () function

• 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).

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 7


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

• SPA Quick check for easy validation directly on production


– Validate optimizer statistics refresh/gather before publishing
– Validate recommendations from the SQL Tuning Advisor (SQL Profiles, Index recommendations )

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 8


SQL Profiles Vs SQL Plan Baselines: Use Cases, Pros/Cons
SQL Profiles SQL Plan Baselines
• Use case: Reactive, SQL performance is sub- • Use case: Proactive, you already know SQL
optimal, invoke SQL Tuning Advisor on high load performance is good and would like to seed the
or business critical SQL known plan to the optimizer
Pros: Pros:
• A SQL Profile contains auxiliary information that • Preserves the known plans, useful in a very
corrects the cardinality estimated in a sub- predictable environment
optimal Plan. Cons:
• Flexible and better approach with volatile data, • In a volatile environment, hard to know a good
not locked in by table sizes or existing access plan.
structures • Application SQL should be executed more than
• SQL Profiles with Indexes (recommendations) once to capture the baseline
can significantly improve performance • If access structures change or dropped, may not
be able to use the required plan

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 9


SQL Profiles Vs SQL Plan Baselines
SQL Profiles SQL Plan Baselines
• Contains auxiliary information that mitigates the • Consists of a set of accepted plans, a set of
defects in a sub-optimal plan. existing plans known to be efficient.
• Profiles provide additional information to the • Aides the optimizer to select the best plan from
optimizer to help select the best plan among the accepted plans.
• Doesn't constrain the optimizer to any specific • Constrain the optimizer to only select from a set
plan, which is why they can be shared. of accepted plans.
• Are more like extended statistics, better • A preventive mechanism that records and
information for the optimizer to decide about evaluates the execution plans of SQL statements
how many rows will flow out of a step in the over time.
plan.
• Useful if you are more conservative and want to
• Useful when you want the system to adapt
control which plans are used.
immediately to changes like new object
statistics.

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 10


New Features and Enhancements (DB 12.1.0.2)

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |


New Features
• AWR Warehouse
• EM Express
• In Memory Advisor
• Adaptive Query Optimization

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 2


AWR Warehouse

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 3


AWR Warehouse - Business Drivers

• AWR is the de facto performance


repository for Oracle databases since
10g
• Default retention period of 8 days
prevents diagnosis of long term
Supply
Finance CRM
Chain
performance problems (“Compare
performance during this quarter’s
books close with last quarter’s”)
120%
120% 120%
90%
• Increasing AWR retention period
90% 90%

60% 60%
increases storage overhead and cost
60%

30% 30% 30%


in critical production environments
0% 0%
0%

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 4


AWR Warehouse - Architecture

• Central warehouse configured for long


term AWR data retention
• Historical and ongoing AWR snapshots
collected from databases enabled for
AWR warehouse
• ETL jobs moves snapshots from source
databases into AWR warehouse
efficiently using Oracle Data Pump
• Retention period configurable for
weeks, months, years or forever
(default)

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 5


AWR Warehouse Features
• Warehouse dashboard tracking ETL jobs
• All AWR features available on long term
AWR data
– Performance page
– AWR report
– ASH analytics
– Compare Period ADDM
– Compare Period Report
• Integrated seamlessly into EM UI
• Zero runtime overhead on source
Production databases

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 6


EM Express

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 8


Oracle Enterprise Manager Database Express 12c
Integrated, GUI Management Tool for Database Administration

Comprehensive
Integrated Install Small Footprint
Administration
• Pre-configured & installed • Disk: 20 MB • Basic admin support for:
with the database • Runtime: zero when idle • Storage management
• Runs inside database • Minimal CPU, memory • Security management
• No extra MW components overhead • Configuration management
• Leverages XDB server inside • 100% of UI rendering • Advanced performance
db for web services performed in browser diagnostics and tuning
• Supports SI, RAC, SE, EE • DB Server only runs SQL

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 9


Enterprise Manager Database Express Menus

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 10


Database Performance Hub

Unified Performance Monitoring


• 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

• Dedicated tab for RAC

• Historical view of SQL Monitoring reports

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 11


Oracle Database In-Memory Central

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 12


In-Memory Central

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |


Oracle Database In-Memory Advisor

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 14


Oracle Database In-Memory Advisor: Challenges

• Optimizing database In-Memory Column Store configuration for maximum


performance

• Actionable recommendations
– Workload based cost/benefit analysis
– In-memory area population plan

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 15


Features

• Assist with IM Column Store size selection


• Recommend tables, partitions and sub-partitions for a given IM Column Store
size
• Use workload and performance data to prioritize objects
• Take into account differences in disk and memory footprint, as well as
compression ratios

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 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

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 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

• Column specific recommendations


– Recommend specific columns to be loaded in memory instead of the entire object.
Useful for wide tables.

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 18


Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 19
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 20
Adaptive Query Optimization

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 21


Adaptive Query Optimization

Set of capabilities that enable optimizer to

• Make run time adjustments execution plans

• Discover additional information that can lead to better statistics

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 22


Adaptive Plan Types

• 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.

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 23


Adaptive Statistics – Dynamic Statistics

• When OPTIMIZER_DYNAMIC_SAMPLING parameter is set to 11, statistics are gathered before


statement execution and cached as dynamic statistics.

• Even when enabled, factors like predicate complexity, existing base statistics and
total execution time expected determines whether to gather dynamics statistics or not.

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 24


Adaptive Statistics – Automatic Reoptimization

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.

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 25


Adaptive Statistics – Automatic Reoptimization

• 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.

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 26


Adaptive Statistics – SQL Plan Directives

• 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

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |


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

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |

Das könnte Ihnen auch gefallen