Tuning slow queries after an upgrade

Similar documents
Quo Vadis SQLTXPLAIN

Incrementally Updating Backups Tips and Tricks

Big Data analytics in insurance

EZY Intellect Pte. Ltd., #1 Changi North Street 1, Singapore

Oracle Database 12c Performance Management and Tuning

Infrastructure Consolidation with OCI

Oracle Database 12c: Performance Management and Tuning

Oracle Database 11g: Performance Tuning DBA Release 2

Copyright 2018, Oracle and/or its affiliates. All rights reserved.

Oralogic Education Systems

Oracle Database 11g: Performance Tuning DBA Release 2

Infrastructure at your Service. In-Memory-Pläne für den 12.2-Optimizer: Teuer oder billig?

Learning Objectives : This chapter provides an introduction to performance tuning scenarios and its tools.

Performance Problems

PERFORMANCE TUNING TRAINING IN BANGALORE

Implement SAML 2.0 SSO in WLS using IDM Federation Services

In the Oracle Database 12c: Performance Management and

OpenWorld 2018 SQL Tuning Tips for Cloud Administrators

SQL Gone Wild: Taming Bad SQL the Easy Way (or the Hard Way) Sergey Koltakov Product Manager, Database Manageability

CC13c LifeCycle Management. Infrastructure at your Service.

Oracle Database 11g : Performance Tuning DBA Release2

Copyright 2012, Oracle and/or its affiliates. All rights reserved.

Oracle Database 11g: Real Application Testing & Manageability Overview

Demystifying SQL Tuning: Tips and Techniques for SQL Experts

Top 7 Plan Stability Pitfalls & How to Avoid Them. Neil Chandler Chandler Systems Ltd UK

<Insert Picture Here> DBA Best Practices: A Primer on Managing Oracle Databases

Databases Clone using ACFS. Infrastructure at your Service.

Oracle 1Z0-054 Exam Questions and Answers (PDF) Oracle 1Z0-054 Exam Questions 1Z0-054 BrainDumps

DOAG 2013 Oracle 12c Backup & Recovery

1Z Oracle Database Performance and Tuning Essentials 2015 Exam Summary Syllabus Questions

1Z Upgrade to Oracle Database 12cm Exam Summary Syllabus Questions

Using Automatic Workload Repository for Database Tuning: Tips for Expert DBAs. Kurt Engeleiter Product Manager

The Oracle SQLT Utility. By Kevin Gilpin, Rolta TUSC Wednesday March 14, 2012

Oracle EXAM - 1Z Oracle Database 11g: Performance Tuning. Buy Full Product.

Database Performance Analysis Techniques Using Metric Extensions and SPA

This presentation is for informational purposes only and may not be incorporated into a contract or agreement.

Manually Create Sql Profile Oracle 10g

KillTest *KIJGT 3WCNKV[ $GVVGT 5GTXKEG Q&A NZZV ]]] QORRZKYZ IUS =K ULLKX LXKK [VJGZK YKX\OIK LUX UTK _KGX

Monitoring WebLogic with WLDF

Session id: The Self-Managing Database: Guided Application and SQL Tuning

PASS4TEST. IT Certification Guaranteed, The Easy Way! We offer free update service for one year

ORACLE 11gR2 DBA. by Mr. Akal Singh ( Oracle Certified Master ) COURSE CONTENT. INTRODUCTION to ORACLE

Oracle Database 12c. The Best Oracle Database 12c Tuning Features for Developers and DBAs. Presented by: Alex Zaballa, Oracle DBA

SQL Tuning for Expert DBAs

Trouble-free Upgrade to Oracle Database 12c with Real Application Testing

Identifying Performance Problems in a Multitenant Environment

What is Real Application Testing?

<Insert Picture Here>

Infrastructure at your Service. Oracle over Docker. Oracle over Docker

Oracle Support for IBM Linux on System Z Update

RAC Performance Monitoring and Diagnosis using Oracle Enterprise Manager. Kai Yu Senior System Engineer Dell Oracle Solutions Engineering

Oracle Database 10g The Self-Managing Database

Managing Oracle Database 12c with Oracle Enterprise Manager 12c

OracleMan Consulting

Oracle Database 18c and Autonomous Database

Moving Databases to Oracle Cloud: Performance Best Practices

Oracle Database 11g for Experienced 9i Database Administrators

Oracle Diagnostics Pack For Oracle Database

Adaptive

Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12


New Features in SQL That Will Change the Way You Tune

<Insert Picture Here> Reduce Problem Resolution Time with Oracle Database 11g Diagnostic Framework

Oracle Database 10g: New Features for Administrators Release 2

Manage Change With Confidence: Upgrading to Oracle Database 11g with Oracle Real Application Testing

SQL Server 2014 Performance Tuning and Optimization

<Insert Picture Here> DBA s New Best Friend: Advanced SQL Tuning Features of Oracle Database 11g

HOW TO PERFORM AN EBS DATABASE HEALTH CHECK BEFORE GOING TO THE CLOUD DIMAS CHBANE ACCENTURE ENKITEC GROUP

Oracle Database 11g: New Features for Administrators DBA Release 2

Oracle 1Z0-514 Exam Questions and Answers (PDF) Oracle 1Z0-514 Exam Questions 1Z0-514 BrainDumps

55144-SQL Server 2014 Performance Tuning and Optimization

Tuna Helper Proven Process for SQL Tuning. Dean Richards Senior DBA, Confio Software

Oracle 1Z0-417 Exam Questions and Answers (PDF) Oracle 1Z0-417 Exam Questions 1Z0-417 BrainDumps

Infrastructure at your Service. DOAG Webinar. ODA 12c new features. ODA 12c new features

Oracle Database 11g: Manageability Overview. An Oracle White Paper August 2007

Neil Chandler, Chandler Systems Oracle & SQL Server DBA

Katharina Römer Principal Sales Consultant STCC Stuttgart ORACLE Deutschland GmbH

ORACLE 11g R2 New Features

Taming Banner 7 on Oracle 10g

<Insert Picture Here> Managing Oracle Exadata Database Machine with Oracle Enterprise Manager 11g

Who Changed My Plan? Prasanth Kothuri, CERN

Triangle SQL Server User Group Adaptive Query Processing with Azure SQL DB and SQL Server 2017

Course Outline. Performance Tuning and Optimizing SQL Databases Course 10987B: 4 days Instructor Led

1z0-062.exam.215q 1z0-062 Oracle Database 12c: Installation and Administration

Oracle Database 11g: New Features for Administrators Release 2

Essential (free) Tools for DBA!

Monitoring & Tuning Azure SQL Database

Query Optimizer, Who Influences & How it works ++ optimization techniques

Oracle Database 12c R2: New Features for 12c R1 Administrators Ed 1

Oracle DBA Course Content

Session 1079: Using Real Application Testing to Successfully Migrate to Exadata - Best Practices and Customer Case Studies

Exam 1Z0-061 Oracle Database 12c: SQL Fundamentals

Oracle 11g New Features

Oracle Database 11g: Self-Managing Database - The Next Generation

Oracle 1Z Oracle Database 11g Performance Tuning.

(10393) Database Performance Tuning Hands-On Lab

ORACLE DIAGNOSTICS PACK

RDBMS & WLS Consolidation with ODA X5-2

Oracle Database 11g: Administration Workshop I Release 2

Optimizing SQL Transactions

Transcription:

Tuning slow queries after an upgrade

Who we are Experts At Your Service > Over 50 specialists in IT infrastructure > Certified, experienced, passionate Based In Switzerland > 100% self-financed Swiss company > Over CHF8 mio. Turnover Leading In Infrastructure Services > More than 150 customers in CH, D & F > Over 50 SLAs dbi FlexService contracted Tuning slow query after an upgrade 08.09.2017 Page 2

About me Clemens Bleile Senior Consultant +41 78 677 51 09 clemens.bleile[at]dbi-services.com Tuning slow query after an upgrade 08.09.2017 Page 3

Agenda 1.Upgrade problems 2.Addressing slow queries 3.Summary dbi services 26.04.2015 Page 4

Upgrade problems > Challenges > Best practices 2 1 3 Tuning slow query after an upgrade 08.09.2017 Page 5

Upgrade problems Challenges >90% of so-called upgrade problems aren't really upgrade problems but performance issues after the upgrade Typical problem areas: Optimizer - execution plans Queries are slow Reports or Batches take longer to complete Increased resource requirements Page 6

Upgrade problems Best practices proactively 1 Test, test, test: Issues: Execution Plan change due to Optimizer enhancements/changes. New features. Changed parameters. Page 7

Upgrade problems Best practices proactively 2: Be prepared Use what s available: Automatic Workload Repository (AWR)/Statspack Automatic Database Diagnostic Monitor (ADDM) Active Session History (ASH) SQL Plan Management (SQL Plan Baselines) Real Application Testing (RAT), SQL Plan Analyzer (SPA) SQLTXPLAIN and/or SQLd360 Page 8

Upgrade problems Best practices proactively 3 Gather stats correctly (you may check the Statistics Advisor in 12.2.) Patch proactively (apply the recommended patches: MOS Note 756388.1, 756671.1) Check MOS Note Things to Consider to Avoid Poor Performance or Wrong Results on 12.1.0.2 (Doc ID 2034610.1) when upgrading to 12.1. Check the Alerts for your new release: ALERT: Oracle 12c Release 1 (12.1) Support Status and Alerts (Doc ID 1565065.1) ALERT: Oracle 12c Release 2 (12.2) Support Status and Alerts (Doc ID 2239821.1) Page 9

Upgrade problems Best practices proactively 4: Be prepared 12.1.: Consider switching to the 12.2-behavior of adaptive optimizer features: See Note Recommendations for Adaptive Features in Oracle Database 12c (Adaptive Statistics & 12c SQL Performance) (Doc ID 2187449.1) Avoid migrating multiple components at a time Use OS watcher Keep the old environment for some time Know the new features (!!!) Adaptive Query Optimization ADAPTIVE PLANS Join Methods Parallel Distribution ADAPTIVE STATISTICS Dynamic Statistics Automatic Reoptimization SQL Plan Directives Page 10

Upgrade problems Best practices reactively: Articles in MOS There are lots of MOS Notes about Upgrade issues and slow (Query-) Performance: Troubleshooting a Server Upgrade Resulting in Slow Query Performance (Doc ID 160089.1) Query with Unchanged Execution Plan is Slower than Previously (Doc ID 223806.1) Avoiding and Resolving Database Performance Related Issues After Upgrade (Doc ID 1528847.1) BUT BOTTOM LINE: Proactively test your application Be prepared for issues after the Upgrade. Especially know what tools (like SQLTXPLAIN) can do for you. Page 11

Adressing slow queries > The usual reaction > Quick wins: Overview > How to do it right? > SQL Plan Management > SQLTXPLAIN > SQLd360 2 1 3 Tuning slow query after an upgrade 08.09.2017 Page 12

Addressing slow queries The usual reaction Gather fresh statistics using dbms_stats Run the SQL Tuning Advisor (when licensed) Switch off new features on system-level OPTIMIZER_ADAPTIVE_FEATURES = FALSE in 12.1. OPTIMIZER_FEATURES_ENABLE = <previous release> Possible issues with above approach It often does not help (!!!) It has a global affect Change on system level affects all SQL OPTIMIZER_ADAPTIVE_FEATURES in 12.1 covers adaptive plans AND statistics Additional index suggested by the Tuning Advisor affects many SQL Page 13

Addressing slow queries Quick wins: Overview Fix the previous plan as a temporary workaround IMPORTANT: Whenever possible change locally (on SQL-statement level), not globally (on system level) Move a SQL Plan Baseline (or Outline) from the previous release database Use SQLPatch (SQL Repair Advisor which does not require an additional license in EE) to fix a plan SQL Tuning Advisor (if licensed) Set the OPTIMIZER_FEATURES_ENABLE-parameter to the previous release. Use the hint /*+ OPTIMIZER_FEATURES_ENABLE('<version>') */ through a SQL Patch or SQL Plan Baseline. Switch off new features (e.g. 12.1. adaptive features) in a test environment and create a SQL Plan Baseline. Page 14

Addressing slow queries How to do it right? Identify the slow SQL Do an analysis Fix the issue Page 16

Addressing slow queries How to do it right? Identify the slow SQL(s) Identify the slow SQL Instrumented Application Cloud Control Performance pages: Top Activity, ASH Analytics. AWR/ADDM/Statspack Shared Pool select sql_id, child_number, executions, elapsed_time/executions/1000000 elap_sec_per_exec from v$sql where executions > 0 and last_active_time > (sysdate 1/24) and elapsed_time/executions/1000000 > 10; 10046 Trace Page 17

Addressing slow queries How to do it right? Do an analysis Do an analysis Doing an in-depth analysis usually takes too long: IN-DEPTH OFTEN TAKES TOO LONG Find the root cause The solution may require application changes, additional objects (indexes, constraints) or additional statistics Find the good plan from before the upgrade May still be in the AWR when it reached the threshold to be reported Use the old or new environment to reproduce the good plan and get it from the Shared Pool Use tools like SQLTXPLAIN (MOS Note 215187.1) and SQLd360 (http://mauro.pagano.com) to get all needed data Find a good plan quickly using proven methods E.g. visualize objects and statistics and hint the query with Dan Tow s method Page 18

Addressing slow queries How to do it right? Fix the issue Plan from before the Upgrade: Fix the issue locally without modifying the application SQL Plan Management (SQL Plan Baseline) SQL Profile SQL Patch Outline (in Standard Edition) to previous plan Page 19

Addressing slow queries How to do it right? Fix the issue: SQL Plan Baseline SQL Plan Baseline: Alternative 1 Get the good plan from the previous environment: Manually Create a SQL Tuning Set in your old environment and move it to the new version Use dbms_spm.load_plans_from_sqlset to load a plan from the tuning set See MOS How to Load SQL Execution Plans in to a STS so that they can be Transferred (to 11g) and Loaded into a SQL Plan Baseline. (Doc ID 801033.1) With a script SQLd360: sqld360-master/sql/sqld360_create_sql_baseline.sql Page 20

Addressing slow queries How to do it right? Fix the issue: SQL Plan Baseline SQL Plan Baseline: Alternative 2 Get the good plan with a hint on the new version: Manual steps: Create a SQL Plan Baseline for the bad plan Run the query with adjusted settings (hint, session-parameter) to get a good plan Associate the SQL_ID and PLAN_HASH_VALUE of the good plan to the SQL_HANDLE of the Baseline retval := dbms_spm.load_plans_from_cursor_cache( sql_handle => <sql_handle baseline bad plan>, sql_id => <sql_id good plan>, plan_hash_value => <plan hash value good plan> ); Scripted: Use SQLTXPLAIN: sqlt/utl/coe_load_sql_baseline.sql Page 21

Addressing slow queries How to do it right? Fix the issue: SQL Profile SQL Profile usually suggested by the Tuning Advisor: Used when cardinality estimation is wrong It s a statement level statistic correction. Reasons: data correlation, join estimation, etc. It adds OPT_ESTIMATE() hints to the query Table cardinality factor Join cardinality factor Index selectivity factor It scales the estimation, so still reliable if volume grows Page 22

Addressing slow queries How to do it right? Fix the issue: SQL Profile SQL Profile with SQLTXPLAIN: Alternative 3 Can be used to fix a plan Interesting, because of FORCE MATCHING feature Scripts in sqlt/utl: coe_load_sql_profile.sql the same as coe_load_sql_baseline.sql, but as a SQL Profile coe_xfr_sql_profile.sql creates a script, which can run on any DB. Allows to adjust FORCE_MATCHING. coe_gen_sql_profile.sql creates scripts for all plans found in AWR and Shared Pool. Page 23

Addressing slow queries How to do it right? Fix the issue: SQL Patch SQL Patch (SQL Repair Advisor) May check if the advisor suggests a SQL Patch Can be used to add other hints to SQL When we cannot change the code And the chosen execution plan is bad Bug in an access path that leads to ORA-600 Bug in a transformation that gives wrong result SQL- See MOS Note How To Use DBMS_SQLDIAG To Diagnose Query Performance Issues (Doc ID 1386802.1) In 12.2. DBMS_SQLDIAG has an official method to add hints to SQL: create_sql_patch/drop_sql_patch. Apply patch 17203284 to get this functionality officially in 12.1. https://oracle-base.com/articles/11g/sql-repair-advisor-11g Page 24

Addressing slow queries How to do it right? Fix the issue: SQL Patch SQL Patch: Alternative 4 (add a hint to a SQL) https://blogs.oracle.com/optimizer/using-sql-patch-to-add-hints-to-a-packaged-application https://blogs.oracle.com/optimizer/adding-and-disabling-hints-using-sql-patch 12.2. (and 12.1. with patch 17203284): retval := dbms_sqldiag.create_sql_patch( sql_id => '<sql_id with bad plan>', hint_text => '<additional hint for the SQL>'); SQL- 11g and 12.1. (without patch 17203284): DECLARE cl_sql_text CLOB; BEGIN SELECT SQL_FULLTEXT INTO cl_sql_text from gv$sqlarea where sql_id = '<sql id of the query>'; sys.dbms_sqldiag_internal.i_create_patch(sql_text=>cl_sql_text, hint_text=>'bind_aware', name=> 'SQL_Patch_BIND_AWARE'); end; / Page 25

Addressing slow queries How to do it right? Fix the issue: SQL Patch SQL Patch in SQLTXPLAIN coe_gen_sql_patch.sql Create a SQL Patch with a specified hint and produce a 10053 Trace Do not use it in a Multitenant and/or 12.2.-DB SQL- Page 26

Summary 1 2 3 Tuning slow query after an upgrade 08.09.2017 Page 27

Summary Be prepared for the Upgrade Use new features to test the new release with your SQL/application if possible Become familiar with the tool SQLTXPLAIN. Alternatively/complementary use SQLd360. Go with the Oracle recommended patches. Review the alerts Oracle has provided for your target release. Use the OS watcher black box. Keep the old environment and thoroughly test the application before migrating. Page 28

Summary Tune slow queries after the Upgrade For the significant slow queries: Focus is to get to previous plans asap Tune local, i.e. at statement level Many tools and utilities in SQLTXPLAIN and SQLd360 make your life easier to change plans without touching the SQL: Generate a SQL Plan Baseline / SQL Profile with the good plan Generate a SQL Baseline in the old environment and copy it If you cannot get back to a previous plan Consider Dan Tow s method as it is quite fast After implementing a workaround a deeper analysis HAS TO follow Page 29

Basel Delémont Zürich Nyon Any questions? Please do ask! We would love to boost your IT-Infrastructure How about you? Tuning slow query after an upgrade 08.09.2017 Page 30