1. 2 SQL Tuning for Smarties, Dummies and Everyone in Between Jagan Athreya Director, Database Manageability, Oracle Arup Nanda Senior Director, Database.

Slides:



Advertisements
Similar presentations
Using the SQL Access Advisor
Advertisements

Enhancing Productivity with MySQL 5.6 New Features
Sameer Marwa – Infogig Consulting Khaled Yagoub – Oracle Development
1 Senn, Information Technology, 3 rd Edition © 2004 Pearson Prentice Hall James A. Senns Information Technology, 3 rd Edition Chapter 7 Enterprise Databases.
Zhongxing Telecom Pakistan (Pvt.) Ltd
Technische Universität München + Hewlett Packard Laboratories Dynamic Workload Management for Very Large Data Warehouses Juggling Feathers and Bowling.
The 4 T’s of Test Automation:
Distributed Systems Architectures
Copyright © 2003 Pearson Education, Inc. Slide 1 Computer Systems Organization & Architecture Chapters 8-12 John D. Carpinelli.
By Rick Clements Software Testing 101 By Rick Clements
14 Copyright © 2005, Oracle. All rights reserved. System Management Tasks and Techniques.
Refreshing Materialized Views
12 Copyright © 2005, Oracle. All rights reserved. Query Rewrite.
6 Copyright © 2005, Oracle. All rights reserved. Building Applications with Oracle JDeveloper 10g.
Custom Statutory Programs Chapter 3. Customary Statutory Programs and Titles 3-2 Objectives Add Local Statutory Programs Create Customer Application For.
ORACLE DATABASE HIGH AVAILABILITY & ORACLE 11GR2 DATA GUARD 1 Güneş EROL.
Database Systems: Design, Implementation, and Management
Performance Tuning Methods Author: Vladimir Andreev Semantec GmbH Lector: Stoyan Ivanov Semantec Bulgaria OOD Semantec GmbH Benzstr. 32 D Herrenberg,
I n t e g r i t y - S e r v i c e - E x c e l l e n c e Headquarters U.S.A.F. 1 Commodity Councils 101 NAME (S) SAF/AQCDATE.
Tuning: overview Rewrite SQL (Leccotech)Leccotech Create Index Redefine Main memory structures (SGA in Oracle) Change the Block Size Materialized Views,
1 Proven Process for SQL Tuning Dean Richards Senior DBA, Confio Software.
Kurt Engeleiter Product Manager Database Manageability
9 Copyright © 2006, Oracle. All rights reserved. Automatic Performance Management.
Database Performance Tuning and Query Optimization
Chapter 9. Performance Management Enterprise wide endeavor Research and ascertain all performance problems – not just DBMS Five factors influence DB performance.
13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.
Module 13: Performance Tuning. Overview Performance tuning methodologies Instance level Database level Application level Overview of tools and techniques.
Overview of performance tuning strategies Oracle Performance Tuning Allan Young June 2008.
QA practitioners viewpoint
Database Performance Tuning and Query Optimization
1.
11 Copyright © Oracle Corporation, All rights reserved. Managing Tables.
9 Copyright © 2004, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
Access Tables 1. Creating a Table Design View Define each field and its properties Data Sheet View Essentially spreadsheet Enter fields You must go to.
1 tRelational/DPS Overview. 2 ADABAS Data Transfer: business needs and issues tRelational & DPS Overview Summary Questions? Demo Agenda.
1 Use or disclosure of data contained on this sheet is subject to the restriction on the title page of this proposal or quotation. An Introduction to Data.
4 Oracle Data Integrator First Project – Simple Transformations: One source, one target 3-1.
KAIST Computer Architecture Lab. The Effect of Multi-core on HPC Applications in Virtualized Systems Jaeung Han¹, Jeongseob Ahn¹, Changdae Kim¹, Youngjin.
Materialized Views.
PSSA Preparation.
Chapter 11 Creating Framed Layouts Principles of Web Design, 4 th Edition.
The DDS Benchmarking Environment James Edmondson Vanderbilt University Nashville, TN.
Chapter 13 The Data Warehouse
Management Information Systems, 10/e
1 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
12 Copyright © 2005, Oracle. All rights reserved. Proactive Maintenance.
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | 2 Hidden Gems of APEX David Gale Software Engineer Oracle Application Express November,
Oracle 11g Real Application Testing: Avoiding Performance Regressions with SQL Performance Analyzer Khaled Yagoub, Pete Belknap, Benoit Dageville, Karl.
Introduction and simple using of Oracle Logistics Information System Yaxian Yao
DBA’s New Best Friend: Oracle Database 10g and 11g SQL Performance Analyzer Prabhaker Gongloor (GP) Khaled Yagoub Pete Belknap Database Manageability.
Michael Sit Solution Specialists Manager Oracle Corporation.
1 Robert Wijnbelt Health Check your Database A Performance Tuning Methodology.
Oracle9i Performance Tuning Chapter 1 Performance Tuning Overview.
The Self-Managing Database: Guided Application and SQL Tuning Mohamed Ziauddin Consulting Member of Technical Staff Oracle Corporation Session id:
Oracle Tuning Considerations. Agenda Why Tune ? Why Tune ? Ways to Improve Performance Ways to Improve Performance Hardware Hardware Software Software.
SQL Tuning made much easier with SQLTXPLAIN (SQLT) Mauro Pagano Senior Principal Technical Support Engineer Oracle Confidential – Internal/Restricted/Highly.
Oracle9i Performance Tuning Chapter 12 Tuning Tools.
Quick Tips for Database Performance Tuning Sergey Koltakov Kurt Engeleiter Product Manager.
Rajesh Bhat Director, PLM Analytics Applications
1 Chapter 8 Execution Plan Management. 2 Overview of Execution Plan Management Review techniques to – override optimizer – Improve optimizer’s decisions.
SQL Server Statistics DEMO SQL Server Statistics SREENI JULAKANTI,MCTS.MCITP,MCP. SQL SERVER Database Administration.
3 Copyright © 2006, Oracle. All rights reserved. Designing and Developing for Performance.
Improve query performance with the new SQL Server 2016 query store!! Michelle Gutzait Principal Consultant at
Closing the Query Processing Loop in Oracle 11g Allison Lee, Mohamed Zait.
Session Name Pelin ATICI SQL Premier Field Engineer.
11 Copyright © 2009, Oracle. All rights reserved. Enhancing ETL Performance.
Antonio Abalos Castillo
Get Verified Oracle 1z0-062 Study Material - Oracle 1z0-062 Exam Dumps PDF Realexamdumps.com
Managing Performance by SQL Tuning
Recommending Materialized Views and Indexes with the IBM DB2 Design Advisor (Automating Physical Database Design) Jarek Gryz.
Presentation transcript:

1

2 SQL Tuning for Smarties, Dummies and Everyone in Between Jagan Athreya Director, Database Manageability, Oracle Arup Nanda Senior Director, Database Architecture, Starwood Hotels and Resorts Novices

3 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 Oracles products remains at the sole discretion of Oracle.

4 Outline SQL Tuning Challenges SQL Tuning Solutions – New Feature Overview Problem Root Causes and their Solutions Preventing SQL Problems Q & A

5 SQL Tuning Challenges Real-world DBA and Development Teams DBA team – Mostly average, some superstars – Superstars take most of the burden – over-stretched Development staff – Mostly non-Oracle skills – Java, C++ – Usually considers the DB as a black box – Writing efficient queries, troubleshooting performance issues is delegated to DBAs

6 SQL Tuning Challenges Production Performance Situation: – Query from hell pops up – Brings the database to its knees – DBA is blamed for the failure Response – DBA: Developer should be taking care of this. – Developer: Why is the DBA not aware of this problem? – Manager: DBA will review all queries and approve them. Challenge – What is the most efficient way to manage this process?

7 SQL Tuning Challenges Change Causing Problems Situation – New SQL statements added as part of application patch deployment – Database upgrades – Database patching Response – Users: How will the application perform after the changes? – DBA: How do I ensure that our SLA remains intact after the changes are rolled out? Challenge – How to reduce business risk while absorbing new technologies?

8 SQL Tuning Challenges Optimizer Statistics Management Situation – Data in Production has evolved over time. Have the optimizer statistics stayed current? Response DBA: – Will statistics refresh break something? – What will happen if we dont collect? – How often should I collect the statistics ? – What happens when you collect a new set? Challenge – What is the recommended strategy for managing optimizer statistics to ensure the best performance?

9 SQL Tuning Challenges Bad Plans – Diagnosis and Resolution No time to find the root cause. How to prevent this from recurring? Bind variables: How do you prevent bad plans based on choice of bind variables? How to diagnose a bad plan – trace, endless pouring over traces – Wrongly constructed predicates How to fix a bad plan – Hints? change of code? – Baselines vs. SQL Profiles – Pick out a single SQL or a bunch from the shared pool

10 Outline SQL Tuning Challenges SQL Tuning Solutions – New Feature Overview Problem Root Causes and their Solutions Preventing SQL Problems Q & A

11 Automatically monitors long running SQL Enabled out-of-the-box with no performance overhead Monitors each SQL execution Exposes monitoring statistics – Global execution level – Plan operation level – Parallel Execution level Guides tuning efforts Real-Time SQL Monitoring Looking Inside SQL Execution

12 PL/SQL monitoring including associated high load SQL monitored recursively Exadata aware I/O performance monitoring and associated metric data Capture rich metadata such as bind values, session details e.g. user, program, client_id and error codes and error messages Save as Active Report for rich interactive offline analysis New capabilities in SQL Monitoring New in Oracle Database 11g Release 2

13 DEMO

14 Application Tuning Automatic SQL Tuning Automatic SQL Tuning Identifies high-load SQL from AWR Tunes SQL using SQL Profiles Implements greatly improved SQL plans (optional) Performance benefit of advice provided SQL Profiling tunes execution plan without changing SQL text Enables transparent tuning for packaged applications Applications SQL High-Load Packaged Apps + SQL Profile Customizable Apps + SQL Advice Customizable Apps + Indexes & MVs + Partitions Well-Tuned SQL Automatic Tuning Optimizer

15 Automatic SQL Tuning New in Oracle Database 11g Release 2 SQL Tuning Advisor NEW: Identifies alternate execution plans using real-time and historical performance data NEW: Recommends parallel profile if it will improve SQL performance significantly (2x or more) Administrator SQL Comprehensive SQL Tuning Recommendations Gather Missing or Stale Statistics Create a SQL Profile Add Missing Access Structures Modify SQL Constructs Adopt Alternative Execution Plan Create Parallel SQL Profile SQL SQL Tuning Advisor

16 SQL Tuning for Developers Integration with Visual Studio Introduced in Oracle Developer Tools for Visual Studio Release Oracle Performance Analyzer – Tune running applications with the help of ADDM Query Window – Tune individual SQL statements with STA Server Explorer – Manage AWR snapshots and ADDM tasks

17 Agenda SQL Tuning Challenges SQL Tuning Solutions – New Feature Overview Problem Root Causes and their Solutions Preventing SQL Problems Q & A

18 What makes SQL go bad? Root Causes of Poor SQL Performance 1.Optimizer statistics issues a.Stale/Missing statistics b.Incomplete statistics c.Improper optimizer configuration d.Upgraded database: new optimizer e.Changing statistics f.Rapidly changing data 2.Application Issues a.Missing access structures b.Poorly written SQL statements 3.Cursor sharing issues a.Bind-sensitive SQL with bind peeking b.Literal usage 4.Resource and contention issues a.Hardware resource crunch b.Contention (row lock contention, block update contention) c.Data fragmentation 5.Parallelism issues a.Not parallelized (no scaling to large data) b.Improperly parallelized (partially parallelized, skews)

19 What makes SQL go bad? Root Causes of Poor SQL Performance 1.Optimizer statistics issues a.Stale/Missing statistics b.Incomplete statistics c.Improper optimizer configuration d.Upgraded database: new optimizer e.Changing statistics f.Rapidly changing data 2.Application Issues 3.Cursor sharing issues 4.Resource and contention issues 5.Parallelism issues

20 Oracle Optimizer Statistics Inaccurate statistics Suboptimal Plans CBO Optimizer Statistics Table Statistics Column Statistics Index Statistics Partition Statistics System Statistics

21 Oracle Optimizer Statistics Preventing SQL Regressions Automatic Statistics Collection Job (stale or missing) Out-of-the box, runs in maintenance window Configuration can be changed (at table level) Gathers statistics on user and dictionary objects Uses new collection algorithm with accuracy of compute and speed faster than sampling of 10% Incrementally maintains statistics for partitioned tables – very efficient Set DBMS_STATS.SET_GLOBAL_PREFS Nightly Novice Mode

22 Oracle Optimizer Statistics Preventing SQL Regressions Extended Statistics Extended Optimizer Statistics provides a mechanism to collect statistics on a group of related columns: Function-Based Statistics Multi-Column Statistics Full integration into existing statistics framework Automatically maintained with column statistics DBMS_STATS.CREATE_EXTENDED_STATS Pending Statistics Allows validation of statistics before publishing Disabled by default To enable, set table/schema PUBLISH setting to FALSE DBMS_STATS.SET_TABLE_PREFS('SH','CUSTOMERS','PUBLISH','false') To use for validation ALTER SESSION SET optimizer_pending_statistics = TRUE; Publish after successful verification Expert Mode

23 1.Optimizer statistics issues 2.Application Issues a.Missing access structures b.Poorly written SQL statements 3.Cursor sharing issues 4.Resource and contention issues 5.Parallelism issues What makes SQL go bad? Root Causes of Poor SQL Performance

24 Identify performance problems using ADDM Automatic Database Diagnostic Monitor Provides database and cluster-wide performance diagnostic Throughput centric - Focus on reducing time DB time Identifies top SQL: Shows SQL impact Frequency of occurrence Pinpoints root cause: – SQL stmts waiting for Row Lock waits – SQL stmts not shared Novice Mode

25 Identify High Load SQL Using Top Activity Performance Page Identify Top SQL by DB Time: CPU I/O Non-idle waits Different Levels of Analysis Historical analysis AWR data Performance Page Real-time analysis ASH data More granular analysis Enables identification of transient problem SQL Top Activity Page Tune using SQL Tuning Advisor Top Activity Novice Mode

26 Advanced SQL Tuning Universe of Access Structures Indexes: B-tree indexes, B-tree cluster indexes, Hash cluster indexes, Global and local indexes, Reverse key indexes, Bitmap indexes, Function-based indexes, Domain indexes Materialized Views: Primary Key materialized views, Object materialized views ROWID materialized views Complex materialized views Partitioned Tables: Range partitioning, Hash partitioning, List partitioning, Composite partitioning, Interval Partitioning, REF partitioning, Virtual Column Based partitioning B-tree index Novice+ Mode

27 SQL Access Advisor: Partition Advisor Indexes Materialized views Materialized views logs SQL Access Advisor Representative Workload Partitioned objects Automatic Tuning Optimizer Access Path Analysis Novice+ Mode

28 SQL Access Advisor Advanced Options Workload filtering Limited vs. advanced mode Tablespaces for access structures Hypothetical workload tuning Factoring in the cost of creation Space limitations for indexes and MVs Expert Mode

29 1.Optimizer statistics issues 2.Application Issues 3.Cursor sharing issues a.Literal usage b.Bind-sensitive SQL with bind peeking 4.Resource and contention issues 5.Parallelism issues What makes SQL go bad? Root Causes of Poor SQL Performance

30 What makes SQL go bad? a. Literal Usage Issue SELECT * FROM jobs WHERE min_salary > 12000; Library Cache SELECT * FROM jobs WHERE min_salary > 15000; SELECT * FROM jobs WHERE min_salary > 10000; SELECT * FROM … Sharing Cursors is good! cursor_sharing ={exact, force, similar} Expert Mode

31 What makes SQL go bad? b. Bind Peeking Issue Processed_Flag Y Y Y Y N CBO 10g IRS FTS 1 99 Full Table Scan Index Range Scan Two different optimal plans for different bind values Problem: Binds will affect optimality in any subsequent uses of the stored plan N Mode

32 Fixing problems with Adaptive Cursor Sharing Adaptive Cursor Sharing SELECT * FROM emp WHERE wage := wage_value Selectivity Ranges: Same Plan Different Plan Same Plan, Expand Interval Expert Mode

33 Agenda SQL Tuning Challenges SQL Tuning Solutions – New Feature Overview Problem Root Causes and their Solutions Preventing SQL Problems Q & A

34 Preventing problems with SQL Plan Management Problem: changes in the environment cause plans to change Plan baseline is established Statement log Plan history HJ GB Plan baseline GB NL GB Parse SQL statement is parsed again and a different plan is generated New plan is not executed but marked for verification

35 Oracle Database 9 or 10g Stored Outlines OH Schema HJ GB HJ CREATE_STORED_OUTLINES=true CREATE_STORED_OUTLINES=false 4. Upgrade to 11g Oracle Database 11g No plan regressions HJ GB HJ 5. Migrate Stored Outlines into SPM Plan Baseline Plan History HJ GB HJ 1. Begin with 2. Run all SQL in the Application and auto create a Stored Outline for each one 3. After Store Outlines are captured Stored Outlines OH Schema HJ GB HJ SQL Plan Management Migration of Stored Outlines to Plan Baselines

36 SQL Performance Analyzer (SPA) Validate statistics refresh with SPA Steps: 1.Capture SQL workload in STS using automatic cursor cache capture capability 2.Execute SPA pre-change trial 3.Refresh statistics using PENDING option 4.Execute SPA post-change trial 5.Run SPA report comparing SQL execution statistics Before PUBLISHing stats: Remediate individual few SQL for plan regressions: SPM, STA Revert to old statistics if too many regressions observed Validating upgrade with SPA Analysis Report Compare SQL Performance SQL plans + stats Pre-change Trial Post-change Trial SQL Workload

37 Conclusion Identify, Resolve, Prevent Identify ADDM, Top Activity, SQL Monitoring Resolve Tuning Advisor, Access Advisor, Auto Stat Collection Top Activity, ADDM, SQL Monitoring Prevent SPA SPM 1.Production Performance 2.Change Causing Problems 3.Optimizer Statistics Management 4.Bad plans – Diagnosis and Resolution

38