SlideShare ist ein Scribd-Unternehmen logo
1 von 67
Downloaden Sie, um offline zu lesen
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
SQL Tuning for Expert DBAs
GP (Gongloor Prabhaker)
Senior Director of Product Management
Oracle Management Cloud, Oracle Corporation
Konstantin Kerekovski,
DBA, Raymond James Financial Inc.
Oct 03, 2017
Confidential – Oracle Internal/Restricted/Highly Restricted
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
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.
Confidential – Oracle Internal/Restricted/Highly Restricted 3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
SQL Tuning: Challenges and existing solutions
Proactive approach and tips
Reactive approach and tips
Customer Case study
1
2
3
4
Confidential – Oracle Internal/Restricted/Highly Restricted 4
Please visit us at Demo Grounds:
Moscone West, SOA-052, Database Monitoring and Performance
Management with Oracle Enterprise Manager
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
SQL Tuning: Challenges and existing
solutions
Confidential – Oracle Internal/Restricted/Highly Restricted 5
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
SQL Tuning: Challenges and existing solutions
Proactive approach and tips
Reactive approach and tips
Customer Case study
1
2
3
4
Confidential – Oracle Internal/Restricted/Highly Restricted 6
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
SQL Tuning: Why is guess work involved?
Confidential – Oracle Internal/Restricted/Highly Restricted 7
Lack of Automated , E2E
and scalable solution
Resource ContentionOptimizer Related Application Specific
Issues
End-user Expertise
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
SQL Performance Issues: Broad categories
Confidential – Oracle Internal/Restricted/Highly Restricted 8
OptimizerRelated
• Stale/Missing
statistics
• Incomplete
statistics
• Improper
optimizer
configuration
• Upgraded
Database:
new
optimizer
• Rapidly
changing data
• Stale/Missing
statistics
• Incomplete
statistics
• Improper
optimizer
configuration
• Upgraded
Database:
new
optimizer
• Rapidly
changing data
ResourceRelated
•Hardware
resource
crunch
•Contention
(row lock/ block
contention)
•Not parallelized
(no scaling to
large data)
•Improperly
parallelized
(partially
parallelized,
skews)
•Hardware
resource
crunch
•Contention
(row lock/ block
contention)
•Not parallelized
(no scaling to
large data)
•Improperly
parallelized
(partially
parallelized,
skews)
ApplicationIssues
• Missing
access
structures
• Poorly
written SQL
statements
• Bind-sensitive
SQL with bind
peeking
(Cursor
Sharing)
• Literal usage
• Missing
access
structures
• Poorly
written SQL
statements
• Bind-sensitive
SQL with bind
peeking
(Cursor
Sharing)
• Literal usage
LackofSQL&OptimizerExpertise
• Limited
knowledge of
SQL and
Optimizer
• Tunes
individual or
few
statements
vs. entire
workload
• Limited
knowledge of
SQL and
Optimizer
• Tunes
individual or
few
statements
vs. entire
workload
LackofAutomation
• Manual
effort, time
consuming
• Lack of
scalability
with high
volume SQL
(100K)
• Unintuitive
techniques
and point
solutions
• Manual
effort, time
consuming
• Lack of
scalability
with high
volume SQL
(100K)
• Unintuitive
techniques
and point
solutions
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
SQL Tuning: Existing solutions
• How DBAs tune SQL today?
– Use SQL Trace to identify offending SQL solution
• Prohibitive on production
– Disable index access by modifying predicates (to_char, to_number)
– Change init.ora parameters (optimizer_..)
– Adding indexes
• Most apps are already over-indexed
– Materialized Views
– Partitioning, etc.
• Existing solutions have severe limitations, are not scalable and mostly
reactive in nature, use trial and error methodology
Confidential – Oracle Internal/Restricted/Highly Restricted 9
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Proactive approach and tips
Confidential – Oracle Internal/Restricted/Highly Restricted 10
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
SQL Tuning: Challenges and existing solutions
Proactive approach and tips
Reactive approach and tips
Customer Case study
1
2
3
4
Confidential – Oracle Internal/Restricted/Highly Restricted 11
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 12
Proactive Approach
Become the “Proactive DBA” using Oracle’s rich tool set!
• A DBA has Oracle’s rich tool set available to identify problems and remediate problems
before they happen in production.
• Proactive DBA should use the following tools:
– ADDM to detect systemic problems and remediate them by following ADDM recommendations*
– Automatic SQL Tuning advisor to tune high load SQL statements over time – it is available out of the
box*
– SQL Access Advisor to make sure your application has optimal access structures (indexes and type,
MVs, MV logs, etc.) and partitioning scheme, tune entire workload*
– SPA Quick in production environments to quickly assess impact of routine system changes (for e.g., SQL
Profile validation, optimizer related changes, optimizer refresh statistics) without impacting
production*
– SPA to validate system changes such as migration to Oracle Database Cloud, Exadata Cloud Machine,
etc.* *OOW 2016: Eliminating Guesswork from SQL Tuning [CON6975]
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
SQL Performance Analyzer
Confidential – Oracle Internal/Restricted/Highly Restricted 13
Analysis Report
Compare SQL
Performance
Post-change TrialPre-change Trial
SQL Plans + Statistics SQL Plans + Statistics
– Helps users predict the impact of
system changes on SQL workload
– Low overhead capture of SQL workload
to SQL Tuning Set (STS) on production
system
– Build different SQL trials (experiments)
of SQL statements performance by test
execution or explain plan
– Integrated with STS, SQL Plan
Baselines, & SQL Tuning Advisor to
form an end-to-end solution
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
DBCS Migration Use Case
• As a DBA, you have been tasked by management to migrate your 11.2
database to the latest Cloud DB release. At the same time, the requirement
is to make sure the performance is same or better than before, how can I
accomplish this?
Confidential – Oracle Internal/Restricted/Highly Restricted 14
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Validate Cloud Migration with SPA
On-Premise Oracle Cloud
15
Trial 2: Test Execute or
Explain Plan
Step 1: Capture representative workload to STS
Step 2: Clone On-premise database to Cloud
Analysis Report
Step 3b: Generate SPA Report and
fix regressions
Trial 1: Build (Convert)
from STS
Step3a: Conduct SPA trials
SPA Task
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 16
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 17
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
SPA - Concurrent SQL Execution
• SPA trials are currently executed serially one statement at a time
– When SQL Tuning Sets contain a large number of statements, the trial could take
significant time. For example, EBS suite may have 1 million unique SQL statements
– Under utilized server if using large system
• Concurrent SQL execution within a SPA trial reduces duration to complete
the trial, therefore reduces testing time
– User specifies degree of parallelism with SPA parameter TEST_EXECUTE_DOP
– For example, a SQL Tuning Set with 125,000 statements reduced testing from
12.5 hours to 2 hours with a degree of parallelism of 8
• Tip: Use SPA concurrent SQL execution in test environment for STS with a
large number (thousands or higher) of SQL statements
Confidential – Oracle Internal/Restricted/Highly Restricted 18
New in
18.1
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
SPA – Result Set Validation
• Result set validation required for certain environments – e.g. government
drug research trials, pharma industries, etc. An additional assurance that
SQL produces correct results with new environment / software
• SPA report can be generated for before and after change trials comparing
whether identical result sets were produced
• SPA result set validation enabled with SPA parameter COMPARE_RESULTSET
(defaults to true)
• Tip: Run before and after trials with exact same dataset for result set
validation
• If result sets differ with same input dataset – contact Oracle Support
Confidential – Oracle Internal/Restricted/Highly Restricted 19
New in
18.1
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Reactive approach and tips
Confidential – Oracle Internal/Restricted/Highly Restricted 20
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
SQL Tuning: Challenges and existing solutions
Proactive Approach and tips
Reactive Approach and tips
Customer Case study
1
2
3
4
Confidential – Oracle Internal/Restricted/Highly Restricted 21
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
SQL Tuning Tips - Reactive Approach
• Proactive SQL Tuning should resolve most of your day-to-day issues,
however sometimes reactive tuning is needed
• DBA should use the following tools for reactive SQL Tuning:
– ASH Analytics for transient performance analysis and drilling down on SQL dimensions (by execution
plan operation, SQL_ID, PDB, Action, Module, etc.)
– SQL Monitor for complex run-time execution statistics on long running or Parallel executions such as
which plan operation line that consumes resources such as CPU and I/O, overall PGA usage and Parallel
distribution
– SQL Tuning Advisor getting comprehensive analysis and recommendations on problematic SQL
statements such as profiles, statistics and new access structure
Confidential – Oracle Internal/Restricted/Highly Restricted 22
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Tip: Use Real-Time SQL Monitoring For Detailed Execution
Statistics On Long Running Or Parallel Executions
• Enabled out-of-the-box with no performance impact
• Automatically monitors SQL executions that:
– Consume more than 5 seconds of CPU or I/O time
– Are running parallel: PQ, PDML, PDDL
• Monitors each execution independently
• Exposes monitoring statistics at multiple levels
– Global execution level
– Plan operation level (Plan Tuning)
– Parallel Execution level (PX Tuning)
• Guides your tuning efforts
• SQL level metrics
—CPU, I/O requests, throughput, PGA, temp space
• Graphical explain plan
• I/O statistics for each operation
Confidential – Oracle Internal/Restricted/Highly Restricted 23
Looking inside the SQL
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Real-Time SQL Monitoring
Confidential – Oracle Internal/Restricted/Highly Restricted 24
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Real-Time SQL Monitoring
Confidential – Oracle Internal/Restricted/Highly Restricted 25
Looking inside the SQL
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Real-Time SQL Monitoring
Confidential – Oracle Internal/Restricted/Highly Restricted 26
Looking inside the SQL
• Can also be accessed via
– ASH Analytics -> Select an SQL ID -> Select SQL Monitor from Detail section.
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Real-Time SQL Monitoring
• Case Study 1 – Adaptive Plans
• Case Study 2 – Long Execution plan
• Case Study 3 – PL/SQL Monitoring
• Case Study 4 – Poor indexing
• Case Study 5 – Parallel Execution Downgrade
Confidential – Oracle Internal/Restricted/Highly Restricted 27
Use cases
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal 29
Real-time SQL Monitoring with
Adaptive Plans
Generate script for problem SQL
with binds and execute
(6 min)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
SQL Monitoring Case Study 1
Confidential – Oracle Internal/Restricted/Highly Restricted 30
Case Study 1: Adaptive Plans
• How can I determine if a query has self tuned with the adaptive plan feature?
• Can I identify the values of my bind variables?
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
SQL Monitoring Use Cases
Confidential – Oracle Internal/Restricted/Highly Restricted 31
Case Study 1: Adaptive Plans
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
• Comprehensive view of execution plan
• Easy to pinpoint operations and objects that consume
the most resources
Confidential – Oracle Internal/Restricted/Highly Restricted 32
SQL Monitoring Use Cases
Case Study 2: Analyzing Large SQL Execution Plans
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 33
SQL Monitoring Use Cases
Case Study 2: Analyzing Large SQL Execution Plans
SELECT /*+ MONITOR */ avg(ss_quantity),avg(ss_ext_sales_price),avg(ss_ext_wholesale_cost),sum(ss_ext_wholesale_cost)
from store_sales ,store ,customer_demographics ,household_demographics,customer_address,date_dim
where s_store_sk = ss_store_sk
and ss_sold_date_sk = d_date_sk and d_year = 2001
and (
(ss_hdemo_sk=hd_demo_sk and cd_demo_sk = ss_cdemo_sk and cd_marital_status = 'M’
and cd_education_status = '4 yr Degree‘ and ss_sales_price between 100.00 and 150.00 and hd_dep_count = 3 )
or
(ss_hdemo_sk=hd_demo_sk and cd_demo_sk = ss_cdemo_sk and cd_marital_status = 'D’ and cd_education_status = 'Primary'
and ss_sales_price between 50.00 and 100.00 and hd_dep_count = 1 )
or
(ss_hdemo_sk=hd_demo_sk and cd_demo_sk = ss_cdemo_sk and cd_marital_status = 'U’
and cd_education_status = 'Advanced Degree‘ and ss_sales_price between 150.00 and 200.00 and hd_dep_count = 1 )
)
and(
(ss_addr_sk = ca_address_sk and ca_country = 'United States‘ and ca_state in ('KY', 'GA', 'NM')
and ss_net_profit between 100 and 200 )
or
(ss_addr_sk = ca_address_sk and ca_country = 'United States‘ and ca_state in ('MT', 'OR', 'IN')
and ss_net_profit between 150 and 300 )
or
(ss_addr_sk = ca_address_sk and ca_country = 'United States‘ and ca_state in ('WI', 'MO', 'WV')
and ss_net_profit between 50 and 250 )
)
• Q: I have a complex query with a complex query plan, how can I identify which
operations and objects consume the most resources?
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 34
SQL Monitoring Use Cases
Case Study 2: Analyzing Large SQL Execution Plans
• Q: I have a complex query with a complex query plan, how can I identify which
operations and objects consume the most resources?
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 35
SQL Monitoring Use Cases
Case Study 2: Analyzing Large SQL Execution Plans
• Q: I have a complex query with a complex query plan, how can I identify which
operations and objects consume the most resources?
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 36
SQL Monitoring Use Cases
Case Study 2: Analyzing Large SQL Execution Plans
• Q: I have a complex query with a complex query plan, how can I identify which
operations and objects consume the most resources?
• Solution: All activity is against STORE_SALES. Consider partitioning the table.
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
SQL Monitoring Use Cases
Confidential – Oracle Internal/Restricted/Highly Restricted 37
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 © 2017, Oracle and/or its affiliates. All rights reserved. |
SQL Monitoring Use Cases
Confidential – Oracle Internal/Restricted/Highly Restricted 38
Case Study 3: Real-Time PL/SQL Monitoring
• Q: I have a PL/SQL procedure that takes a long time, can I identify which SQL statement
that is my largest resource consumer?
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
SQL Monitoring Use Cases
Confidential – Oracle Internal/Restricted/Highly Restricted 39
Case Study 3: Real-Time PL/SQL Monitoring
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
SQL Monitoring Use Cases
Confidential – Oracle Internal/Restricted/Highly Restricted 40
Case Study 3: Real-Time PL/SQL Monitoring
Most elapsed time
Highest CPU usage
• Q: I have a PL/SQL procedure that takes a long time, can I
identify which SQL statement that is my largest resource
consumer?
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
SQL Monitoring Use Cases
Confidential – Oracle Internal/Restricted/Highly Restricted 41
Case Study 3: Real-Time PL/SQL Monitoring
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
SQL Monitoring Use Cases
Confidential – Oracle Internal/Restricted/Highly Restricted 42
Case Study 3: Real-Time PL/SQL Monitoring
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
SQL Monitoring Use Cases
Confidential – Oracle Internal/Restricted/Highly Restricted 43
Case Study 3: Real-Time PL/SQL Monitoring
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
• Initial Query
• Q: I have added many indexes to my database. I still have several queries with bad
performance. Can I determine if my indexes are used efficiently?
Confidential – Oracle Internal/Restricted/Highly Restricted 45
SQL Monitoring Use Cases
Case Study 4: Poor Indexing
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 46
SQL Monitoring Use Cases
Case Study 4: Poor Indexing
• Q:I have added a large amount of indexes to my database. I still have several queries
with bad performance. Can I identify that my indexes are used efficient?
• Initial Query • Tuned Query
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 47
SQL Monitoring Use Cases
Case Study 4: Poor Indexing
• Q: I have added many indexes to my database. I still have several queries with bad
performance. Can I determine if my indexes are used efficiently?
• Initial Query • Tuned Query • Tuned Query / Cached
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
SQL Monitoring Use Cases
Case Study 5: Parallel Execution Downgrade
• Query requests parallel degree 4. Why is it downgraded to parallel degree 2?
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
SQL Monitoring Use Cases
Case Study 5: Parallel Execution Downgrade
• Query requests parallel degree 4. Why is it downgraded to parallel degree 2?
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
SQL Monitoring Use Cases
Case Study 5: Parallel Execution Downgrade
• Query requests parallel degree 4. Why is it downgraded to parallel degree 2?
select qksxareasons,indx
from x$qksxa_reason
where qksxareasons like '%DOP downgrade%’;
QKSXAREASONS INDX
------------------------------------------------------------ ----------
DOP downgrade due to adaptive DOP 351
DOP downgrade due to resource manager max DOP 352
DOP downgrade due to insufficient number of processes 353
DOP downgrade because slaves failed to join 354
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
SQL Monitoring Use Cases
Case Study 5: Parallel Execution Downgrade
• Query requests parallel degree 4. Why is it downgraded to parallel degree 2?
• Solution: Consider changing the maximum DOP on Resource Consumer Group
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
SQL Tuning Advisor Exadata Enhancement
• SQL Tuning Advisor detects if SQL is executing on
Exadata
• SQL Tuning Advisor privately gathers system statistics
and does analysis with and without these statistics
• If a better execution plan is found with these system
statistics, an Exadata-aware SQL Profile is recommended
• Can result in 10x or better performance improvement
for SQLs which can benefit from Exadata hardware - e.g.
cell smart scans
Confidential – Oracle Internal/Restricted/Highly Restricted 53
NEW IN
18.1
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
SQL Tuning Advisor Exadata Enhancement
Confidential – Oracle Internal/Restricted/Highly Restricted 54
NEW IN
18.1
Without Exadata aware SQL Profile – 1.9 minutes:
With-Exadata aware SQL Profile – 13 seconds:
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
SQL Tuning: Challenges and existing solutions
Proactive Approach and tips
Reactive Approach and tips
Customer Case study
1
2
3
4
Confidential – Oracle Internal/Restricted/Highly Restricted 55
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Customer Case study
Confidential – Oracle Internal/Restricted/Highly Restricted 56
RAYMOND JAMES FINANCIAL
HTTPS://WWW.RAYMONDJAMES.COM/
57
KONSTANTIN KEREKOVSKI
58
Work Experience:
American Express – Senior Oracle DBA, 11g, 12c, RAC, GG, ADG
Raymond James – Senior Oracle DBA, 11g, 12c, Exadata, ODA, RAC, GG, ADG
LinkedIn: www.linkedin.com/in/konstantin-kerekovski-34740071
Speaker:
IOUG Collaborate 2017
SOUG (Suncoast Oracle User Group)
NYOUG (New York Oracle User Group)
THE PROBLEM
59
• Production Oracle Data Integrator (ODI) jobs are running slowly due
to suboptimal execution plans on INSERT INTO XYZ SELECT….
queries.
• The INSERT queries cannot be readily altered due to declarative
nature of ODI and internal Change Management process.
• The business is being impacted because multiple other ETL and
batch jobs depend on the completion of ODI jobs.
PROBLEM IDENTIFICATION
60
The problem was clearly evident in the Top Activity page of OEM for the
database in question.
THE SOLUTION
SQL TUNING ADVISOR
61
PLAN COMPARISON
62
IMPLEMENTATION
63
The implementation of the SQL Profiles and/or statistics gathering is as
simple as following the guided instructions from the OEM SQL Tuning
recommendations screen.
TOP ACTIVITY BEFORE TUNING
64
TOP ACTIVITY AFTER TUNING
THE IMPACT OF SQL TUNING ADVISOR
65
• The long running ODI job’s runtime improved dramatically.
• No development effort was necessary, thus saving money on labor
costs on tuning efforts and regression testing efforts.
• The change was easily implementable and because SQL Profiles
can easily be disabled, the change can be backed out if any issues
arise.
• The change can be easily propagated throughout the entire SDLC
due to the portable nature of SQL Profiles.
• Business processes which depend on ODI jobs to complete were no
longer impacted and completed ahead of schedule.
66
 What is it?
- Extra information to be
used by the optimizer
during parsing.
 When do I use it?
- When you just want to help
the optimizer with extra
information without
dictating a specific
execution plan.
- When SQL Execution
Plans are unstable and
changing adversely due to
issues such as
inaccurate/stale Optimizer
Statistics, bind variable
peeking, etc.
TIP
SHOULD I USE SQL BASELINES OR SQL
PROFILES ?
SQL PROFILE
 What is it?
- A set of stored, approved
execution plans for a given
SQL statement that are used
instead of plans obtained
during normal hard parsing.
 When do I use it?
- During Database Upgrades
for the purpose of avoiding
performance regression due
to new optimizer features (
E.G. Adaptive Plans in 12.1),
missing statistics, etc.
- When you only want one
specific execution plan to be
used.
SQL BASELINE
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
SQL Tuning for Expert DBAs: Summary
Confidential – Oracle Internal/Restricted/Highly Restricted 67
• Become the proactive DBA, use:
– ADDM to detect systemic problems and remediate
them by following ADDM recommendations
– Automatic SQL Tuning Advisor to tune high load SQL
statements over time
– SQL Access Advisor to assure that your application
has optimal access structures (indexes and type,
MVs, MV logs, etc.). Tunes the entire workload
– SPA Quick Check in production environments to
quickly assess impact of routine system changes (for
e.g., optimizer refresh statistics)
– SPA to validate system changes such as migration to
Oracle Database Cloud, Exadata Cloud Machine, etc.
• If you have to perform reactive SQL
tuning, use:
– ASH Analytics to identify your top resource
consumers
– SQL Monitor for detailed execution statistics on
long running or parallel executions
– SQL Tuning Advisor to identify and remediate:
– Stale statistics
– Incorrect cardinality estimations
– Data correlations
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 68
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 69
Con7091 sql tuning for expert db as-oow17_oct2_1507314871265001m0x4

Weitere ähnliche Inhalte

Was ist angesagt?

[Oracle DBA & Developer Day 2016] しばちょう先生の特別講義!!ストレージ管理のベストプラクティス ~ASMからExada...
[Oracle DBA & Developer Day 2016] しばちょう先生の特別講義!!ストレージ管理のベストプラクティス ~ASMからExada...[Oracle DBA & Developer Day 2016] しばちょう先生の特別講義!!ストレージ管理のベストプラクティス ~ASMからExada...
[Oracle DBA & Developer Day 2016] しばちょう先生の特別講義!!ストレージ管理のベストプラクティス ~ASMからExada...
オラクルエンジニア通信
 
Oracle 10g Performance: chapter 02 aas
Oracle 10g Performance: chapter 02 aasOracle 10g Performance: chapter 02 aas
Oracle 10g Performance: chapter 02 aas
Kyle Hailey
 
Understanding my database through SQL*Plus using the free tool eDB360
Understanding my database through SQL*Plus using the free tool eDB360Understanding my database through SQL*Plus using the free tool eDB360
Understanding my database through SQL*Plus using the free tool eDB360
Carlos Sierra
 

Was ist angesagt? (20)

Oracle SQL, PL/SQL Performance tuning
Oracle SQL, PL/SQL Performance tuningOracle SQL, PL/SQL Performance tuning
Oracle SQL, PL/SQL Performance tuning
 
Chasing the optimizer
Chasing the optimizerChasing the optimizer
Chasing the optimizer
 
TFA Collector - what can one do with it
TFA Collector - what can one do with it TFA Collector - what can one do with it
TFA Collector - what can one do with it
 
[Oracle DBA & Developer Day 2016] しばちょう先生の特別講義!!ストレージ管理のベストプラクティス ~ASMからExada...
[Oracle DBA & Developer Day 2016] しばちょう先生の特別講義!!ストレージ管理のベストプラクティス ~ASMからExada...[Oracle DBA & Developer Day 2016] しばちょう先生の特別講義!!ストレージ管理のベストプラクティス ~ASMからExada...
[Oracle DBA & Developer Day 2016] しばちょう先生の特別講義!!ストレージ管理のベストプラクティス ~ASMからExada...
 
Tanel Poder - Scripts and Tools short
Tanel Poder - Scripts and Tools shortTanel Poder - Scripts and Tools short
Tanel Poder - Scripts and Tools short
 
Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1
Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1
Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1
 
A deep dive about VIP,HAIP, and SCAN
A deep dive about VIP,HAIP, and SCAN A deep dive about VIP,HAIP, and SCAN
A deep dive about VIP,HAIP, and SCAN
 
Oracle 10g Performance: chapter 02 aas
Oracle 10g Performance: chapter 02 aasOracle 10g Performance: chapter 02 aas
Oracle 10g Performance: chapter 02 aas
 
しばちょう先生が語る!オラクルデータベースの進化の歴史と最新技術動向#3
しばちょう先生が語る!オラクルデータベースの進化の歴史と最新技術動向#3しばちょう先生が語る!オラクルデータベースの進化の歴史と最新技術動向#3
しばちょう先生が語る!オラクルデータベースの進化の歴史と最新技術動向#3
 
Oracle AFD
Oracle AFDOracle AFD
Oracle AFD
 
Understanding my database through SQL*Plus using the free tool eDB360
Understanding my database through SQL*Plus using the free tool eDB360Understanding my database through SQL*Plus using the free tool eDB360
Understanding my database through SQL*Plus using the free tool eDB360
 
Adapting and adopting spm v04
Adapting and adopting spm v04Adapting and adopting spm v04
Adapting and adopting spm v04
 
SQLd360
SQLd360SQLd360
SQLd360
 
Tanel Poder Oracle Scripts and Tools (2010)
Tanel Poder Oracle Scripts and Tools (2010)Tanel Poder Oracle Scripts and Tools (2010)
Tanel Poder Oracle Scripts and Tools (2010)
 
Oracle AWR Data mining
Oracle AWR Data miningOracle AWR Data mining
Oracle AWR Data mining
 
Oracle sql high performance tuning
Oracle sql high performance tuningOracle sql high performance tuning
Oracle sql high performance tuning
 
Oracle statistics by example
Oracle statistics by exampleOracle statistics by example
Oracle statistics by example
 
Ash architecture and advanced usage rmoug2014
Ash architecture and advanced usage rmoug2014Ash architecture and advanced usage rmoug2014
Ash architecture and advanced usage rmoug2014
 
SQL Monitoring in Oracle Database 12c
SQL Monitoring in Oracle Database 12cSQL Monitoring in Oracle Database 12c
SQL Monitoring in Oracle Database 12c
 
Oracle SQL Tuning for Day-to-Day Data Warehouse Support
Oracle SQL Tuning for Day-to-Day Data Warehouse SupportOracle SQL Tuning for Day-to-Day Data Warehouse Support
Oracle SQL Tuning for Day-to-Day Data Warehouse Support
 

Ähnlich wie Con7091 sql tuning for expert db as-oow17_oct2_1507314871265001m0x4

Suffering from Chronic Patching Pain? Get Relief with Fleet Maintenance [CON6...
Suffering from Chronic Patching Pain? Get Relief with Fleet Maintenance [CON6...Suffering from Chronic Patching Pain? Get Relief with Fleet Maintenance [CON6...
Suffering from Chronic Patching Pain? Get Relief with Fleet Maintenance [CON6...
Timothy Schubert
 
[CON6985]Expanding DBaaS Beyond Data Centers Hybrid Cloud Onboarding via Orac...
[CON6985]Expanding DBaaS Beyond Data Centers Hybrid Cloud Onboarding via Orac...[CON6985]Expanding DBaaS Beyond Data Centers Hybrid Cloud Onboarding via Orac...
[CON6985]Expanding DBaaS Beyond Data Centers Hybrid Cloud Onboarding via Orac...
Bharat Paliwal
 

Ähnlich wie Con7091 sql tuning for expert db as-oow17_oct2_1507314871265001m0x4 (20)

Beyond SQL Tuning: Insider's Guide to Maximizing SQL Performance
Beyond SQL Tuning: Insider's Guide to Maximizing SQL PerformanceBeyond SQL Tuning: Insider's Guide to Maximizing SQL Performance
Beyond SQL Tuning: Insider's Guide to Maximizing SQL Performance
 
MySQL 5.7 NEW FEATURES, BETTER PERFORMANCE, AND THINGS THAT WILL BREAK -- Mid...
MySQL 5.7 NEW FEATURES, BETTER PERFORMANCE, AND THINGS THAT WILL BREAK -- Mid...MySQL 5.7 NEW FEATURES, BETTER PERFORMANCE, AND THINGS THAT WILL BREAK -- Mid...
MySQL 5.7 NEW FEATURES, BETTER PERFORMANCE, AND THINGS THAT WILL BREAK -- Mid...
 
Suffering from Chronic Patching Pain? Get Relief with Fleet Maintenance [CON6...
Suffering from Chronic Patching Pain? Get Relief with Fleet Maintenance [CON6...Suffering from Chronic Patching Pain? Get Relief with Fleet Maintenance [CON6...
Suffering from Chronic Patching Pain? Get Relief with Fleet Maintenance [CON6...
 
Streamline it management
Streamline it managementStreamline it management
Streamline it management
 
What's new in oracle ORAchk & EXAchk 12.2.0.1.3
What's new in oracle ORAchk & EXAchk 12.2.0.1.3What's new in oracle ORAchk & EXAchk 12.2.0.1.3
What's new in oracle ORAchk & EXAchk 12.2.0.1.3
 
206510 p6 upgrade considerations
206510 p6 upgrade considerations206510 p6 upgrade considerations
206510 p6 upgrade considerations
 
OOW16 - Testing Oracle E-Business Suite Best Practices [CON6713]
OOW16 - Testing Oracle E-Business Suite Best Practices [CON6713]OOW16 - Testing Oracle E-Business Suite Best Practices [CON6713]
OOW16 - Testing Oracle E-Business Suite Best Practices [CON6713]
 
OOW15 - managing oracle e-business suite auditing and security
OOW15 - managing oracle e-business suite auditing and securityOOW15 - managing oracle e-business suite auditing and security
OOW15 - managing oracle e-business suite auditing and security
 
Rohit_Panot
Rohit_PanotRohit_Panot
Rohit_Panot
 
New availability features in oracle rac 12c release 2 anair ss
New availability features in oracle rac 12c release 2 anair   ssNew availability features in oracle rac 12c release 2 anair   ss
New availability features in oracle rac 12c release 2 anair ss
 
Oracle Openworld Presentation with Paul Kent (SAS) on Big Data Appliance and ...
Oracle Openworld Presentation with Paul Kent (SAS) on Big Data Appliance and ...Oracle Openworld Presentation with Paul Kent (SAS) on Big Data Appliance and ...
Oracle Openworld Presentation with Paul Kent (SAS) on Big Data Appliance and ...
 
MySQL in oracle_environments(Part 2): MySQL Enterprise Monitor & Oracle Enter...
MySQL in oracle_environments(Part 2): MySQL Enterprise Monitor & Oracle Enter...MySQL in oracle_environments(Part 2): MySQL Enterprise Monitor & Oracle Enter...
MySQL in oracle_environments(Part 2): MySQL Enterprise Monitor & Oracle Enter...
 
Novinky v Oracle Database 18c
Novinky v Oracle Database 18cNovinky v Oracle Database 18c
Novinky v Oracle Database 18c
 
I one Service Offerings
I one Service OfferingsI one Service Offerings
I one Service Offerings
 
[CON6985]Expanding DBaaS Beyond Data Centers Hybrid Cloud Onboarding via Orac...
[CON6985]Expanding DBaaS Beyond Data Centers Hybrid Cloud Onboarding via Orac...[CON6985]Expanding DBaaS Beyond Data Centers Hybrid Cloud Onboarding via Orac...
[CON6985]Expanding DBaaS Beyond Data Centers Hybrid Cloud Onboarding via Orac...
 
Hybrid Cloud : Database-as-a-Service: OOW 16
Hybrid Cloud : Database-as-a-Service: OOW 16 Hybrid Cloud : Database-as-a-Service: OOW 16
Hybrid Cloud : Database-as-a-Service: OOW 16
 
18. Madhur Hemnani - Result Orientated Innovation with Oracle HR Analytics
18. Madhur Hemnani - Result Orientated Innovation with Oracle HR Analytics18. Madhur Hemnani - Result Orientated Innovation with Oracle HR Analytics
18. Madhur Hemnani - Result Orientated Innovation with Oracle HR Analytics
 
Meetup Oracle Database: 3 Analizar, Aconsejar, Automatizar… las nuevas funcio...
Meetup Oracle Database: 3 Analizar, Aconsejar, Automatizar… las nuevas funcio...Meetup Oracle Database: 3 Analizar, Aconsejar, Automatizar… las nuevas funcio...
Meetup Oracle Database: 3 Analizar, Aconsejar, Automatizar… las nuevas funcio...
 
Apouc 2014-enterprise-manager-12c
Apouc 2014-enterprise-manager-12cApouc 2014-enterprise-manager-12c
Apouc 2014-enterprise-manager-12c
 
Optimize with Open Source
Optimize with Open SourceOptimize with Open Source
Optimize with Open Source
 

Kürzlich hochgeladen

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Kürzlich hochgeladen (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

Con7091 sql tuning for expert db as-oow17_oct2_1507314871265001m0x4

  • 1.
  • 2. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | SQL Tuning for Expert DBAs GP (Gongloor Prabhaker) Senior Director of Product Management Oracle Management Cloud, Oracle Corporation Konstantin Kerekovski, DBA, Raymond James Financial Inc. Oct 03, 2017 Confidential – Oracle Internal/Restricted/Highly Restricted
  • 3. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 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. Confidential – Oracle Internal/Restricted/Highly Restricted 3
  • 4. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Program Agenda SQL Tuning: Challenges and existing solutions Proactive approach and tips Reactive approach and tips Customer Case study 1 2 3 4 Confidential – Oracle Internal/Restricted/Highly Restricted 4 Please visit us at Demo Grounds: Moscone West, SOA-052, Database Monitoring and Performance Management with Oracle Enterprise Manager
  • 5. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | SQL Tuning: Challenges and existing solutions Confidential – Oracle Internal/Restricted/Highly Restricted 5
  • 6. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Program Agenda SQL Tuning: Challenges and existing solutions Proactive approach and tips Reactive approach and tips Customer Case study 1 2 3 4 Confidential – Oracle Internal/Restricted/Highly Restricted 6
  • 7. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | SQL Tuning: Why is guess work involved? Confidential – Oracle Internal/Restricted/Highly Restricted 7 Lack of Automated , E2E and scalable solution Resource ContentionOptimizer Related Application Specific Issues End-user Expertise
  • 8. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | SQL Performance Issues: Broad categories Confidential – Oracle Internal/Restricted/Highly Restricted 8 OptimizerRelated • Stale/Missing statistics • Incomplete statistics • Improper optimizer configuration • Upgraded Database: new optimizer • Rapidly changing data • Stale/Missing statistics • Incomplete statistics • Improper optimizer configuration • Upgraded Database: new optimizer • Rapidly changing data ResourceRelated •Hardware resource crunch •Contention (row lock/ block contention) •Not parallelized (no scaling to large data) •Improperly parallelized (partially parallelized, skews) •Hardware resource crunch •Contention (row lock/ block contention) •Not parallelized (no scaling to large data) •Improperly parallelized (partially parallelized, skews) ApplicationIssues • Missing access structures • Poorly written SQL statements • Bind-sensitive SQL with bind peeking (Cursor Sharing) • Literal usage • Missing access structures • Poorly written SQL statements • Bind-sensitive SQL with bind peeking (Cursor Sharing) • Literal usage LackofSQL&OptimizerExpertise • Limited knowledge of SQL and Optimizer • Tunes individual or few statements vs. entire workload • Limited knowledge of SQL and Optimizer • Tunes individual or few statements vs. entire workload LackofAutomation • Manual effort, time consuming • Lack of scalability with high volume SQL (100K) • Unintuitive techniques and point solutions • Manual effort, time consuming • Lack of scalability with high volume SQL (100K) • Unintuitive techniques and point solutions
  • 9. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | SQL Tuning: Existing solutions • How DBAs tune SQL today? – Use SQL Trace to identify offending SQL solution • Prohibitive on production – Disable index access by modifying predicates (to_char, to_number) – Change init.ora parameters (optimizer_..) – Adding indexes • Most apps are already over-indexed – Materialized Views – Partitioning, etc. • Existing solutions have severe limitations, are not scalable and mostly reactive in nature, use trial and error methodology Confidential – Oracle Internal/Restricted/Highly Restricted 9
  • 10. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Proactive approach and tips Confidential – Oracle Internal/Restricted/Highly Restricted 10
  • 11. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Program Agenda SQL Tuning: Challenges and existing solutions Proactive approach and tips Reactive approach and tips Customer Case study 1 2 3 4 Confidential – Oracle Internal/Restricted/Highly Restricted 11
  • 12. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 12 Proactive Approach Become the “Proactive DBA” using Oracle’s rich tool set! • A DBA has Oracle’s rich tool set available to identify problems and remediate problems before they happen in production. • Proactive DBA should use the following tools: – ADDM to detect systemic problems and remediate them by following ADDM recommendations* – Automatic SQL Tuning advisor to tune high load SQL statements over time – it is available out of the box* – SQL Access Advisor to make sure your application has optimal access structures (indexes and type, MVs, MV logs, etc.) and partitioning scheme, tune entire workload* – SPA Quick in production environments to quickly assess impact of routine system changes (for e.g., SQL Profile validation, optimizer related changes, optimizer refresh statistics) without impacting production* – SPA to validate system changes such as migration to Oracle Database Cloud, Exadata Cloud Machine, etc.* *OOW 2016: Eliminating Guesswork from SQL Tuning [CON6975]
  • 13. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | SQL Performance Analyzer Confidential – Oracle Internal/Restricted/Highly Restricted 13 Analysis Report Compare SQL Performance Post-change TrialPre-change Trial SQL Plans + Statistics SQL Plans + Statistics – Helps users predict the impact of system changes on SQL workload – Low overhead capture of SQL workload to SQL Tuning Set (STS) on production system – Build different SQL trials (experiments) of SQL statements performance by test execution or explain plan – Integrated with STS, SQL Plan Baselines, & SQL Tuning Advisor to form an end-to-end solution
  • 14. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | DBCS Migration Use Case • As a DBA, you have been tasked by management to migrate your 11.2 database to the latest Cloud DB release. At the same time, the requirement is to make sure the performance is same or better than before, how can I accomplish this? Confidential – Oracle Internal/Restricted/Highly Restricted 14
  • 15. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Validate Cloud Migration with SPA On-Premise Oracle Cloud 15 Trial 2: Test Execute or Explain Plan Step 1: Capture representative workload to STS Step 2: Clone On-premise database to Cloud Analysis Report Step 3b: Generate SPA Report and fix regressions Trial 1: Build (Convert) from STS Step3a: Conduct SPA trials SPA Task
  • 16. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 16
  • 17. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 17
  • 18. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | SPA - Concurrent SQL Execution • SPA trials are currently executed serially one statement at a time – When SQL Tuning Sets contain a large number of statements, the trial could take significant time. For example, EBS suite may have 1 million unique SQL statements – Under utilized server if using large system • Concurrent SQL execution within a SPA trial reduces duration to complete the trial, therefore reduces testing time – User specifies degree of parallelism with SPA parameter TEST_EXECUTE_DOP – For example, a SQL Tuning Set with 125,000 statements reduced testing from 12.5 hours to 2 hours with a degree of parallelism of 8 • Tip: Use SPA concurrent SQL execution in test environment for STS with a large number (thousands or higher) of SQL statements Confidential – Oracle Internal/Restricted/Highly Restricted 18 New in 18.1
  • 19. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | SPA – Result Set Validation • Result set validation required for certain environments – e.g. government drug research trials, pharma industries, etc. An additional assurance that SQL produces correct results with new environment / software • SPA report can be generated for before and after change trials comparing whether identical result sets were produced • SPA result set validation enabled with SPA parameter COMPARE_RESULTSET (defaults to true) • Tip: Run before and after trials with exact same dataset for result set validation • If result sets differ with same input dataset – contact Oracle Support Confidential – Oracle Internal/Restricted/Highly Restricted 19 New in 18.1
  • 20. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Reactive approach and tips Confidential – Oracle Internal/Restricted/Highly Restricted 20
  • 21. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Program Agenda SQL Tuning: Challenges and existing solutions Proactive Approach and tips Reactive Approach and tips Customer Case study 1 2 3 4 Confidential – Oracle Internal/Restricted/Highly Restricted 21
  • 22. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | SQL Tuning Tips - Reactive Approach • Proactive SQL Tuning should resolve most of your day-to-day issues, however sometimes reactive tuning is needed • DBA should use the following tools for reactive SQL Tuning: – ASH Analytics for transient performance analysis and drilling down on SQL dimensions (by execution plan operation, SQL_ID, PDB, Action, Module, etc.) – SQL Monitor for complex run-time execution statistics on long running or Parallel executions such as which plan operation line that consumes resources such as CPU and I/O, overall PGA usage and Parallel distribution – SQL Tuning Advisor getting comprehensive analysis and recommendations on problematic SQL statements such as profiles, statistics and new access structure Confidential – Oracle Internal/Restricted/Highly Restricted 22
  • 23. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Tip: Use Real-Time SQL Monitoring For Detailed Execution Statistics On Long Running Or Parallel Executions • Enabled out-of-the-box with no performance impact • Automatically monitors SQL executions that: – Consume more than 5 seconds of CPU or I/O time – Are running parallel: PQ, PDML, PDDL • Monitors each execution independently • Exposes monitoring statistics at multiple levels – Global execution level – Plan operation level (Plan Tuning) – Parallel Execution level (PX Tuning) • Guides your tuning efforts • SQL level metrics —CPU, I/O requests, throughput, PGA, temp space • Graphical explain plan • I/O statistics for each operation Confidential – Oracle Internal/Restricted/Highly Restricted 23 Looking inside the SQL
  • 24. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Real-Time SQL Monitoring Confidential – Oracle Internal/Restricted/Highly Restricted 24
  • 25. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Real-Time SQL Monitoring Confidential – Oracle Internal/Restricted/Highly Restricted 25 Looking inside the SQL
  • 26. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Real-Time SQL Monitoring Confidential – Oracle Internal/Restricted/Highly Restricted 26 Looking inside the SQL • Can also be accessed via – ASH Analytics -> Select an SQL ID -> Select SQL Monitor from Detail section.
  • 27. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Real-Time SQL Monitoring • Case Study 1 – Adaptive Plans • Case Study 2 – Long Execution plan • Case Study 3 – PL/SQL Monitoring • Case Study 4 – Poor indexing • Case Study 5 – Parallel Execution Downgrade Confidential – Oracle Internal/Restricted/Highly Restricted 27 Use cases
  • 28. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal 29 Real-time SQL Monitoring with Adaptive Plans Generate script for problem SQL with binds and execute (6 min)
  • 29. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | SQL Monitoring Case Study 1 Confidential – Oracle Internal/Restricted/Highly Restricted 30 Case Study 1: Adaptive Plans • How can I determine if a query has self tuned with the adaptive plan feature? • Can I identify the values of my bind variables?
  • 30. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | SQL Monitoring Use Cases Confidential – Oracle Internal/Restricted/Highly Restricted 31 Case Study 1: Adaptive Plans
  • 31. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | • Comprehensive view of execution plan • Easy to pinpoint operations and objects that consume the most resources Confidential – Oracle Internal/Restricted/Highly Restricted 32 SQL Monitoring Use Cases Case Study 2: Analyzing Large SQL Execution Plans
  • 32. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 33 SQL Monitoring Use Cases Case Study 2: Analyzing Large SQL Execution Plans SELECT /*+ MONITOR */ avg(ss_quantity),avg(ss_ext_sales_price),avg(ss_ext_wholesale_cost),sum(ss_ext_wholesale_cost) from store_sales ,store ,customer_demographics ,household_demographics,customer_address,date_dim where s_store_sk = ss_store_sk and ss_sold_date_sk = d_date_sk and d_year = 2001 and ( (ss_hdemo_sk=hd_demo_sk and cd_demo_sk = ss_cdemo_sk and cd_marital_status = 'M’ and cd_education_status = '4 yr Degree‘ and ss_sales_price between 100.00 and 150.00 and hd_dep_count = 3 ) or (ss_hdemo_sk=hd_demo_sk and cd_demo_sk = ss_cdemo_sk and cd_marital_status = 'D’ and cd_education_status = 'Primary' and ss_sales_price between 50.00 and 100.00 and hd_dep_count = 1 ) or (ss_hdemo_sk=hd_demo_sk and cd_demo_sk = ss_cdemo_sk and cd_marital_status = 'U’ and cd_education_status = 'Advanced Degree‘ and ss_sales_price between 150.00 and 200.00 and hd_dep_count = 1 ) ) and( (ss_addr_sk = ca_address_sk and ca_country = 'United States‘ and ca_state in ('KY', 'GA', 'NM') and ss_net_profit between 100 and 200 ) or (ss_addr_sk = ca_address_sk and ca_country = 'United States‘ and ca_state in ('MT', 'OR', 'IN') and ss_net_profit between 150 and 300 ) or (ss_addr_sk = ca_address_sk and ca_country = 'United States‘ and ca_state in ('WI', 'MO', 'WV') and ss_net_profit between 50 and 250 ) ) • Q: I have a complex query with a complex query plan, how can I identify which operations and objects consume the most resources?
  • 33. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 34 SQL Monitoring Use Cases Case Study 2: Analyzing Large SQL Execution Plans • Q: I have a complex query with a complex query plan, how can I identify which operations and objects consume the most resources?
  • 34. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 35 SQL Monitoring Use Cases Case Study 2: Analyzing Large SQL Execution Plans • Q: I have a complex query with a complex query plan, how can I identify which operations and objects consume the most resources?
  • 35. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 36 SQL Monitoring Use Cases Case Study 2: Analyzing Large SQL Execution Plans • Q: I have a complex query with a complex query plan, how can I identify which operations and objects consume the most resources? • Solution: All activity is against STORE_SALES. Consider partitioning the table.
  • 36. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | SQL Monitoring Use Cases Confidential – Oracle Internal/Restricted/Highly Restricted 37 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
  • 37. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | SQL Monitoring Use Cases Confidential – Oracle Internal/Restricted/Highly Restricted 38 Case Study 3: Real-Time PL/SQL Monitoring • Q: I have a PL/SQL procedure that takes a long time, can I identify which SQL statement that is my largest resource consumer?
  • 38. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | SQL Monitoring Use Cases Confidential – Oracle Internal/Restricted/Highly Restricted 39 Case Study 3: Real-Time PL/SQL Monitoring
  • 39. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | SQL Monitoring Use Cases Confidential – Oracle Internal/Restricted/Highly Restricted 40 Case Study 3: Real-Time PL/SQL Monitoring Most elapsed time Highest CPU usage • Q: I have a PL/SQL procedure that takes a long time, can I identify which SQL statement that is my largest resource consumer?
  • 40. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | SQL Monitoring Use Cases Confidential – Oracle Internal/Restricted/Highly Restricted 41 Case Study 3: Real-Time PL/SQL Monitoring
  • 41. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | SQL Monitoring Use Cases Confidential – Oracle Internal/Restricted/Highly Restricted 42 Case Study 3: Real-Time PL/SQL Monitoring
  • 42. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | SQL Monitoring Use Cases Confidential – Oracle Internal/Restricted/Highly Restricted 43 Case Study 3: Real-Time PL/SQL Monitoring
  • 43. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | • Initial Query • Q: I have added many indexes to my database. I still have several queries with bad performance. Can I determine if my indexes are used efficiently? Confidential – Oracle Internal/Restricted/Highly Restricted 45 SQL Monitoring Use Cases Case Study 4: Poor Indexing
  • 44. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 46 SQL Monitoring Use Cases Case Study 4: Poor Indexing • Q:I have added a large amount of indexes to my database. I still have several queries with bad performance. Can I identify that my indexes are used efficient? • Initial Query • Tuned Query
  • 45. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 47 SQL Monitoring Use Cases Case Study 4: Poor Indexing • Q: I have added many indexes to my database. I still have several queries with bad performance. Can I determine if my indexes are used efficiently? • Initial Query • Tuned Query • Tuned Query / Cached
  • 46. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | SQL Monitoring Use Cases Case Study 5: Parallel Execution Downgrade • Query requests parallel degree 4. Why is it downgraded to parallel degree 2?
  • 47. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | SQL Monitoring Use Cases Case Study 5: Parallel Execution Downgrade • Query requests parallel degree 4. Why is it downgraded to parallel degree 2?
  • 48. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | SQL Monitoring Use Cases Case Study 5: Parallel Execution Downgrade • Query requests parallel degree 4. Why is it downgraded to parallel degree 2? select qksxareasons,indx from x$qksxa_reason where qksxareasons like '%DOP downgrade%’; QKSXAREASONS INDX ------------------------------------------------------------ ---------- DOP downgrade due to adaptive DOP 351 DOP downgrade due to resource manager max DOP 352 DOP downgrade due to insufficient number of processes 353 DOP downgrade because slaves failed to join 354
  • 49. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | SQL Monitoring Use Cases Case Study 5: Parallel Execution Downgrade • Query requests parallel degree 4. Why is it downgraded to parallel degree 2? • Solution: Consider changing the maximum DOP on Resource Consumer Group
  • 50. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | SQL Tuning Advisor Exadata Enhancement • SQL Tuning Advisor detects if SQL is executing on Exadata • SQL Tuning Advisor privately gathers system statistics and does analysis with and without these statistics • If a better execution plan is found with these system statistics, an Exadata-aware SQL Profile is recommended • Can result in 10x or better performance improvement for SQLs which can benefit from Exadata hardware - e.g. cell smart scans Confidential – Oracle Internal/Restricted/Highly Restricted 53 NEW IN 18.1
  • 51. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | SQL Tuning Advisor Exadata Enhancement Confidential – Oracle Internal/Restricted/Highly Restricted 54 NEW IN 18.1 Without Exadata aware SQL Profile – 1.9 minutes: With-Exadata aware SQL Profile – 13 seconds:
  • 52. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Program Agenda SQL Tuning: Challenges and existing solutions Proactive Approach and tips Reactive Approach and tips Customer Case study 1 2 3 4 Confidential – Oracle Internal/Restricted/Highly Restricted 55
  • 53. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Customer Case study Confidential – Oracle Internal/Restricted/Highly Restricted 56
  • 55. KONSTANTIN KEREKOVSKI 58 Work Experience: American Express – Senior Oracle DBA, 11g, 12c, RAC, GG, ADG Raymond James – Senior Oracle DBA, 11g, 12c, Exadata, ODA, RAC, GG, ADG LinkedIn: www.linkedin.com/in/konstantin-kerekovski-34740071 Speaker: IOUG Collaborate 2017 SOUG (Suncoast Oracle User Group) NYOUG (New York Oracle User Group)
  • 56. THE PROBLEM 59 • Production Oracle Data Integrator (ODI) jobs are running slowly due to suboptimal execution plans on INSERT INTO XYZ SELECT…. queries. • The INSERT queries cannot be readily altered due to declarative nature of ODI and internal Change Management process. • The business is being impacted because multiple other ETL and batch jobs depend on the completion of ODI jobs.
  • 57. PROBLEM IDENTIFICATION 60 The problem was clearly evident in the Top Activity page of OEM for the database in question.
  • 60. IMPLEMENTATION 63 The implementation of the SQL Profiles and/or statistics gathering is as simple as following the guided instructions from the OEM SQL Tuning recommendations screen.
  • 61. TOP ACTIVITY BEFORE TUNING 64 TOP ACTIVITY AFTER TUNING
  • 62. THE IMPACT OF SQL TUNING ADVISOR 65 • The long running ODI job’s runtime improved dramatically. • No development effort was necessary, thus saving money on labor costs on tuning efforts and regression testing efforts. • The change was easily implementable and because SQL Profiles can easily be disabled, the change can be backed out if any issues arise. • The change can be easily propagated throughout the entire SDLC due to the portable nature of SQL Profiles. • Business processes which depend on ODI jobs to complete were no longer impacted and completed ahead of schedule.
  • 63. 66  What is it? - Extra information to be used by the optimizer during parsing.  When do I use it? - When you just want to help the optimizer with extra information without dictating a specific execution plan. - When SQL Execution Plans are unstable and changing adversely due to issues such as inaccurate/stale Optimizer Statistics, bind variable peeking, etc. TIP SHOULD I USE SQL BASELINES OR SQL PROFILES ? SQL PROFILE  What is it? - A set of stored, approved execution plans for a given SQL statement that are used instead of plans obtained during normal hard parsing.  When do I use it? - During Database Upgrades for the purpose of avoiding performance regression due to new optimizer features ( E.G. Adaptive Plans in 12.1), missing statistics, etc. - When you only want one specific execution plan to be used. SQL BASELINE
  • 64. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | SQL Tuning for Expert DBAs: Summary Confidential – Oracle Internal/Restricted/Highly Restricted 67 • Become the proactive DBA, use: – ADDM to detect systemic problems and remediate them by following ADDM recommendations – Automatic SQL Tuning Advisor to tune high load SQL statements over time – SQL Access Advisor to assure that your application has optimal access structures (indexes and type, MVs, MV logs, etc.). Tunes the entire workload – SPA Quick Check in production environments to quickly assess impact of routine system changes (for e.g., optimizer refresh statistics) – SPA to validate system changes such as migration to Oracle Database Cloud, Exadata Cloud Machine, etc. • If you have to perform reactive SQL tuning, use: – ASH Analytics to identify your top resource consumers – SQL Monitor for detailed execution statistics on long running or parallel executions – SQL Tuning Advisor to identify and remediate: – Stale statistics – Incorrect cardinality estimations – Data correlations
  • 65. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 68
  • 66. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 69