Independent consultant. Oracle ACE Director. Member of OakTable Network. Available for consulting In-house workshops. Performance Troubleshooting

Similar documents
Independent consultant. Oracle ACE Director. Member of OakTable Network. Available for consulting In-house workshops. Performance Troubleshooting

Advanced Oracle Performance Troubleshooting. Query Transformations Randolf Geist

Relational Database Index Design and the Optimizers

Relational Database Index Design and the Optimizers

ORACLE TRAINING CURRICULUM. Relational Databases and Relational Database Management Systems

Query Optimizer MySQL vs. PostgreSQL

Does Exadata Need Performance Tuning? Jože Senegačnik, Oracle ACE Director, Member of OakTable DbProf d.o.o. Ljubljana, Slovenia

Query Optimizer MySQL vs. PostgreSQL

7. Query Processing and Optimization

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

Bloom Filters DOAG Webinar, 12 August 2016 Christian Antognini Senior Principal Consultant

Data Modeling and Databases Ch 9: Query Processing - Algorithms. Gustavo Alonso Systems Group Department of Computer Science ETH Zürich

Advanced Oracle SQL Tuning v3.0 by Tanel Poder

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Data Modeling and Databases Ch 10: Query Processing - Algorithms. Gustavo Alonso Systems Group Department of Computer Science ETH Zürich

Optimizer Challenges in a Multi-Tenant World

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

Oracle DB-Tuning Essentials

ITExamDownload. Provide the latest exam dumps for you. Download the free reference for study

Delegates must have a working knowledge of MariaDB or MySQL Database Administration.

Database Systems CSE 414

Oracle Database 11g: SQL Tuning Workshop

Something to think about. Problems. Purpose. Vocabulary. Query Evaluation Techniques for large DB. Part 1. Fact:

When should an index be used?

How Well Do Relational Database Engines Support

SQL Tuning Reading Recent Data Fast

Module 4. Implementation of XQuery. Part 0: Background on relational query processing

Arrays are a very commonly used programming language construct, but have limited support within relational databases. Although an XML document or

Datenbanksysteme II: Caching and File Structures. Ulf Leser

INFSCI 2711 Database Analysis and Design Example I for Final Exam: Solutions

Oracle 9i Application Development and Tuning

Appendix: Application of the Formal Principle for the Analysis of Performance Problems After an Oracle Migration

Designing for Performance: Database Related Worst Practices ITOUG Tech Day, 11 November 2016, Milano (I) Christian Antognini

20 Essential Oracle SQL and PL/SQL Tuning Tips. John Mullins

Hash table example. B+ Tree Index by Example Recall binary trees from CSE 143! Clustered vs Unclustered. Example

MySQL for Developers. Duration: 5 Days

CS222P Fall 2017, Final Exam

Introduction to Database Systems CSE 414. Lecture 26: More Indexes and Operator Costs

MySQL for Developers. Duration: 5 Days

Data Organization and Processing I

Exadata X3 in action: Measuring Smart Scan efficiency with AWR. Franck Pachot Senior Consultant

Join Selectivity. Jonathan Lewis JL Computer Consultancy London, UK

Advanced Oracle Troubleshooting Live Session. Randolf Geist

Oracle Database New Performance Features

Oracle and Toad Course Descriptions Instructor: Dan Hotka

MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9)

Increasing Database Performance through Optimizing Structure Query Language Join Statement

A Unit of SequelGate Innovative Technologies Pvt. Ltd. All Training Sessions are Completely Practical & Real-time

ORACLE DATABASE 12C INTRODUCTION

MySQL Database Scalability

SQL Server 2014 Performance Tuning and Optimization

Oracle Database 10g The Self-Managing Database

Advanced Database Systems

Querying Data with Transact SQL

<Insert Picture Here> Oracle Database 11g: Neue Features im Oracle Optimizer

CSE 344 Final Review. August 16 th

IBM DB2 LUW Performance Tuning and Monitoring for Single and Multiple Partition DBs

Oral Questions and Answers (DBMS LAB) Questions & Answers- DBMS

Oh! I see a problem. cost = blevel + ceil(selectivity * leaf_blocks) + ceil(selectivity * clustering_factor)

55144-SQL Server 2014 Performance Tuning and Optimization

PHP6 AND MYSQL BIBLE BY STEVE SUEHRING, TIM CONVERSE, JOYCE PARK

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

Cost Based Optimizer CBO: Configuration Roadmap

RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague

Ryan Stephens. Ron Plew Arie D. Jones. Sams Teach Yourself FIFTH EDITION. 800 East 96th Street, Indianapolis, Indiana, 46240

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

Estimating Cardinality: Use of Jonathan Lewis CBO methodology

Oracle Database 11g: SQL Tuning Workshop. Student Guide

High-Performance Distributed DBMS for Analytics

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

Top 5 Issues that Cannot be Resolved by DBAs (other than missed bind variables)

OpenWorld 2018 SQL Tuning Tips for Cloud Administrators

Oracle Database 11g: Performance Tuning DBA Release 2

Oracle Exadata Implementation Strategy HHow to Implement Exadata In-house

Interpreting Explain Plan Output. John Mullins

Oracle Database Performance Tuning, Benchmarks & Replication

SQLSaturday Sioux Falls, SD Hosted by (605) SQL

Outline. Database Tuning. Ideal Transaction. Concurrency Tuning Goals. Concurrency Tuning. Nikolaus Augsten. Lock Tuning. Unit 8 WS 2013/2014

20762B: DEVELOPING SQL DATABASES

Advanced Oracle Troubleshooting Live Session

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

Query Optimization, part 2: query plans in practice

EXAM REF QUERYING DATA WITH TRANSACT-SQL BY ITZIK BEN-GAN

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

Evaluation of Relational Operations: Other Techniques

Outline. Database Management and Tuning. Outline. Join Strategies Running Example. Index Tuning. Johann Gamper. Unit 6 April 12, 2012

Data Warehouse Tutorial For Beginners Sql Server 2008 Book

Oracle Database 11g: Performance Tuning DBA Release 2

Microsoft. [MS20762]: Developing SQL Databases

Under the hood of dynamic and adaptive database features

Database Management and Tuning

Module 9: Selectivity Estimation

CSE 544: Principles of Database Systems

Oracle Database 11g & MySQL 5.6 Developer Handbook (Oracle Press) PDF

Huge market -- essentially all high performance databases work this way

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

IT100: Oracle Administration

Five Hints for Optimising SQL

Adaptive

Optimized Analytical Processing New Features with 11g R2

Transcription:

Independent consultant Available for consulting In-house workshops Cost-Based Optimizer Performance By Design Performance Troubleshooting Oracle ACE Director Member of OakTable Network

Optimizer Basics Key Concepts Proactive: Performance by design Reactive: Troubleshooting

Three main questions you should ask when looking for an efficient execution plan: How much data? How many rows / volume? How scattered / clustered is the data? Caching? => Know your data!

Why are these questions so important? Two main strategies: One Big Job => How much data, volume? Few/many Small Jobs => How many times / rows? => Effort per iteration? Clustering / Caching

Optimizer s cost estimate is based on: How much data? How many rows / volume? (partially) (Caching?) Not at all

Single table cardinality Join cardinality Filter subquery / Aggregation cardinality

Selectivity of predicates applying to a single table

Selectivity of predicates applying to a single table

Selectivity of predicates applying to a single table

Selectivity of predicates applying to a single table Base Cardinality Filtered Cardinality / Filter Ratio

Optimizer challenges Skewed column value distribution Gaps / clustered values Correlated column values Complex predicates and expressions Bind variables

Demo! optimizer_basics_single_table_cardinality_testcase.sql

Impact limited to a single table Influences the favored (Full Table Scan, Index Access etc.) Influences the and (NESTED LOOP, HASH, MERGE) => An incorrect single table cardinality potentially screws up whole!

Oracle joins exactly row sources at a time If more than two row sources need to be joined, join operations are required Many different possible (factorial!)

Tree shape of execution plan

Challenges Getting the right! A join can mean anything between product and a

Getting the right T1, T2 1,000,000 rows 0 rows 1,000 rows T1 T2 1,000 rows

Getting the right T1, T2 Join cardinality = Cardinality T1 * Cardinality T2 * Join selectivity T1 T2

Challenges Semi Joins (EXISTS (), = ANY()) Anti Joins (NOT EXISTS (), <> ALL()) Non-Equi Joins (Range, Unequal etc.)

Even for the most common form of a join - the there are several challenges Non-uniform join column value distribution Partially overlapping join columns Correlated column values Expressions Complex join expressions (multiple AND, OR)

Demo! optimizer_basics_join_cardinality_testcase.sql

Influences the and (NESTED LOOP, HASH, MERGE) => An incorrect join cardinality/selectivity potentially screws up whole!

Data is organized in blocks Many rows can fit into a single block According to a specific data can be either across many different blocks or in the same or few blocks Does make a tremendous difference in terms of efficiency of a Small Job

1,000 rows => visit 1,000 table blocks: 1,000 * 5ms = 5 s

1,000 rows => visit 10 table blocks: 10 * 5ms = 50 ms

Scattered data means potentially many more blocks to compete for the Buffer Cache for the same number of rows => Caching! Scattered data can result in increased physical write (Log Writer, DB Writer)

Most OLTP data has a clustering Data arriving is usually clustered together in a heap organized table Depends on the organization for example can influence this clustering even for heap organized tables

Clustering of data can be influenced by implementation Physical design matters Segment space management (MSSM / ASSM) Partitioning Index/Hash Cluster Index Organized Tables (IOT) Index design / multi-column composite indexes There is a reason why the Oracle internal data dictionary uses all over the place

No table access => only index blocks are visited!

There is only a single measure of clustering in Oracle: The The index clustering factor is represented by a value The logic measuring the clustering factor by default does cater for data clustered across blocks (ASSM!)

Challenges Getting the right There are various reasons why the index clustering factor measured by Oracle might not be Multiple freelists / freelist groups (MSSM) ASSM Partitioning SHRINK SPACE effects

Re-visiting the same recent table blocks

Challenges There is no clustering measurement The optimizer therefore doesn t really have a clue about the You may need to influence the optimizer s decisions if you know about this clustering

Demo! optimizer_basics_inter_table_clustering_testcase.sql

The optimizer s model by default doesn t consider caching of data Every I/O is assumed to be But there is a huge difference between (measured in microseconds) and (measured in milliseconds)

You might have knowledge of particular application data that is and usually stays in the Buffer Cache Therefore certain queries against this hot data can be based on that The optimizer doesn t know about this. You may need to the optimizer s decisions

Oracle obviously played with the idea of introducing an caching component into the cost calculation in 9i and 10g You can see this from the undocumented parameters and as well as the columns and in the data dictionary

It is important to point out that even is not free So even by putting all objects entirely in the Buffer Cache execution plans may still lead to poor performance logical I/O, in particular on hot blocks, can lead to and

and determine whether the or strategy should be preferred If the optimizer gets these estimates right, the resulting will be within the of the given access paths

How to apply these concepts, where to go from here? Read Jonathan Lewis article Designing Efficient SQL at Red Gate s Simple Talk Probably the best coverage of the concepts outlined here including clustering and caching http://www.simple-talk.com/sql/performance/designing-efficient-sql-a-visual-approach/

How to apply these concepts, where to go from here? Read Jonathan Lewis article Designing Efficient SQL at Red Gate s Simple Talk Probably the best coverage of the concepts outlined here including clustering and caching http://www.simple-talk.com/sql/performance/designing-efficient-sql-a-visual-approach/

How to apply these concepts, where to go from here? Read one of Tom Kyte s books to learn more about the pro s and con s of clusters and index organized tables

How to apply these concepts, where to go from here? Read one of Tom Kyte s books to learn more about the pro s and con s of clusters and index organized tables

How to apply these concepts, where to go from here? Learn how to read, interpret and understand Oracle execution plans => Chapter 6 of Troubleshooting Oracle Performance by Christian Antognini This knowledge is required in order to compare your understanding of the query to the optimizer s understanding

How to apply these concepts, where to go from here? Learn how to read, interpret and understand Oracle execution plans => Chapter 6 of Troubleshooting Oracle Performance by Christian Antognini This knowledge is required in order to compare your understanding of the query to the optimizer s understanding

How to apply these concepts, where to go from here? Be aware of Query Transformations: The optimizer might rewrite your query to something that is semantically equivalent but potentially more efficient This might take you by surprise when trying to understand the execution plan favored by the optimizer Query transformation examples by courtesy of Joze Senegacnik (OOW 2010)

How to apply these concepts, where to go from here? Be aware of Query Transformations: The optimizer might rewrite your query to something that is semantically equivalent but potentially more efficient This might take you by surprise when trying to understand the execution plan favored by the optimizer Query transformation examples by courtesy of Joze Senegacnik (OOW 2010)

How to apply these concepts, where to go from here? Be aware of Query Transformations: The optimizer might rewrite your query to something that is semantically equivalent but potentially more efficient This might take you by surprise when trying to understand the execution plan favored by the optimizer Query transformation examples by courtesy of Joze Senegacnik (OOW 2010)

If you want a more formal approach Read SQL Tuning by Dan Tow Teaches a formal approach how to design and visualize an execution plan Focuses on robust execution plans in an OLTP environment The formal approach doesn t take into account clustering and caching, however it is mentioned in the book at some places

If you want a more formal approach Read SQL Tuning by Dan Tow Teaches a formal approach how to design and visualize an execution plan Focuses on robust execution plans in an OLTP environment The formal approach doesn t take into account clustering and caching, however it is mentioned in the book at some places

If you want a more formal approach Read Relational Database Index Design and the Optimizers by Tapio Lahdenmäki and Michael Leach Focuses on index design Provides simple and more advanced formulas allowing to predict the efficiency of queries and indexes Covers clustering and caching

If you want a more formal approach Read Relational Database Index Design and the Optimizers by Tapio Lahdenmäki and Michael Leach Focuses on index design Provides simple and more advanced formulas allowing to predict the efficiency of queries and indexes Covers clustering and caching

For application developers http://use-the-index-luke.com/ Read Use the Index, Luke by Markus Winand Focuses on index design Provides a lot of examples how to design efficient database access using different front-end languages (Java, Perl, PHP, etc.) Also available as free ebook Cross database (Oracle DB2, MySQL )

For application developers http://use-the-index-luke.com/ Read Use the Index, Luke by Markus Winand Focuses on index design Provides a lot of examples how to design efficient database access using different front-end languages (Java, Perl, PHP, etc.) Also available as free ebook Cross database (Oracle DB2, MySQL )

If you want dive into the details of the Cost- Based Optimizer Read Cost-Based Oracle: Fundamentals by Jonathan Lewis Almost six years old Still the best book about the Oracle optimizer Covers the key concepts mentioned here in great detail

If you want dive into the details of the Cost- Based Optimizer Read Cost-Based Oracle: Fundamentals by Jonathan Lewis Almost six years old Still the best book about the Oracle optimizer Covers the key concepts mentioned here in great detail

Q & A