Oracle Optimizer: What s New in Oracle Database 12c? Maria Colgan Master Product Manager

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

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

<Insert Picture Here> Inside the Oracle Database 11g Optimizer Removing the black magic

Understanding Optimizer Statistics With Oracle Database 12c Release 2 O R A C L E W H I T E P A P E R M A R C H

Pitfalls & Surprises with DBMS_STATS: How to Solve Them

Die Wundertüte DBMS_STATS: Überraschungen in der Praxis

An Oracle White Paper April Best Practices for Gathering Optimizer Statistics

Optimizer with Oracle Database 12c Release 2 O R A C L E W H I T E P A P E R J U N E

Best Practices for Gathering Optimizer Statistics with Oracle Database 12c Release 2 O R A C L E W H I T E P A P E R J U N E

Oracle 11g Optimizer Statistics Inderpal S. Johal. Inderpal S. Johal, Data Softech Inc.

Real-World Performance Training SQL Performance

Top 10 Features in Oracle 12C for Developers and DBA s Gary Bhandarkar Merck & Co., Inc., Rahway, NJ USA

Real-World Performance Training SQL Performance

Managing Performance Through Versioning of Statistics

Oracle Database 11gR2 Optimizer Insights

Database statistics gathering: Synopsis

MTA Database Administrator Fundamentals Course

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

D B M G Data Base and Data Mining Group of Politecnico di Torino

Course Modules for MCSA: SQL Server 2016 Database Development Training & Certification Course:

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

Automating Information Lifecycle Management with

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

Exploring Best Practices and Guidelines for Tuning SQL Statements

1z0-063.exam. Number: 1z0-063 Passing Score: 800 Time Limit: 120 min File Version: 3.0. Oracle. 1z Oracle Database 12c: Advanced Administration

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

How To Drop All Tables In A Schema In Oracle 10g

Data Warehouse Tuning. Without SQL Modification

Data Warehousing & Big Data at OpenWorld for your smartphone

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

Slide 2 of 79 12/03/2011

MySQL Database Administrator Training NIIT, Gurgaon India 31 August-10 September 2015

MANAGING COST-BASED OPTIMIZER STATISTICS FOR PEOPLESOFT DAVID KURTZ UKOUG PEOPLESOFT ROADSHOW 2018

Oracle 10g Dbms Stats Gather Table Stats Examples

AUTOMATIC CLUSTERING PRASANNA RAJAPERUMAL I MARCH Snowflake Computing Inc. All Rights Reserved

Firebird in 2011/2012: Development Review

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

Sql Server Syllabus. Overview

Oracle Database 12c: OCM Exam Preparation Workshop Ed 1

Oracle 11g Db Stats Enhancements Inderpal S. Johal. Inderpal S. Johal, Data Softech Inc.

Gather Schema Statistics Oracle 10g Examples

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

Oracle Database 11g for Experienced 9i Database Administrators

Oracle SQL Tuning for Developers Workshop Student Guide - Volume I

Oracle Hyperion Profitability and Cost Management

Oracle 1Z0-515 Exam Questions & Answers

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

7. Query Processing and Optimization

Optimized Analytical Processing New Features with 11g R2

Oracle DB-Tuning Essentials

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

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

1 Dulcian, Inc., 2001 All rights reserved. Oracle9i Data Warehouse Review. Agenda

ORANET- Course Contents

20762B: DEVELOPING SQL DATABASES

Techno India Batanagar Computer Science and Engineering. Model Questions. Subject Name: Database Management System Subject Code: CS 601

The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into

Oracle Database 18c and Autonomous Database

Oracle - Oracle Database 12c: OCM Exam Preparation Workshop Ed 1

Oracle Database 10g: New Features for Administrators Release 2

Oracle 1Z0-053 Exam Questions & Answers

Microsoft. [MS20762]: Developing SQL Databases

Effect of Stats on Two Columns Optimizer Statistics on tables and indexes are vital. Arup Nanda

Developing SQL Databases

Oracle Database 12c: SQL Tuning for Developers

Automatic Parallel Execution Presented by Joel Goodman Oracle University EMEA

Mobile MOUSe MTA DATABASE ADMINISTRATOR FUNDAMENTALS ONLINE COURSE OUTLINE

Oracle Database 11g: SQL Tuning Workshop

Oracle FLEXCUBE Private Banking May 2011

Oracle. Exam Questions 1Z Oracle Database 11g Release 2: SQL Tuning Exam. Version:Demo

Chapter 12: Query Processing

Exploring Oracle Database 11g/12c Partitioning New Features and Best Practices. Ami Aharonovich Oracle ACE & OCP

Explore the Oracle 10g database architecture. Install software with the Oracle Universal Installer (OUI)

Oracle Database 12c: New Features for Administrators NEW

The execution plan for the query is shown in the exhibit. (Click the Exhibit button.)

So you think you know everything about Partitioning?

Cost Based Optimizer CBO: Configuration Roadmap

Greenplum Architecture Class Outline

SQL Server Development 20762: Developing SQL Databases in Microsoft SQL Server Upcoming Dates. Course Description.

Chapter 9. Cardinality Estimation. How Many Rows Does a Query Yield? Architecture and Implementation of Database Systems Winter 2010/11

Oracle 1Z Oracle Database 11g Release 2- SQL Tuning. Download Full Version :

[Contents. Sharing. sqlplus. Storage 6. System Support Processes 15 Operating System Files 16. Synonyms. SQL*Developer

Hive and Shark. Amir H. Payberah. Amirkabir University of Technology (Tehran Polytechnic)

SAS, Sun, Oracle: On Mashups, Enterprise 2.0 and Ideation

"Charting the Course... MOC C: Developing SQL Databases. Course Summary

Learn Well Technocraft

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

Microsoft Developing SQL Databases

Manual Trigger Sql Server 2008 Insert Multiple Rows

Oracle Database 11g: New Features for Oracle 9i DBAs

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

Internals of Active Dataguard. Saibabu Devabhaktuni

.. Spring 2008 CSC 468: DBMS Implementation Alexander Dekhtyar..

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

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

<Insert Picture Here> Controlling resources in an Exadata environment

Data Warehousing 11g Essentials

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

Querying Data with Transact-SQL

Oracle Database In-Memory

Transcription:

Oracle Optimizer: What s New in Oracle Database 12c? Maria Colgan Master Product Manager

PART 3 2

Program Agenda Adaptive Query Optimization Statistics Enhancements What s new in SQL Plan Management 3

Histograms Histograms tell Optimizer about the data distribution in a Column Creation controlled by METHOD_OPT parameter Default create histogram on any column that has been used in the WHERE clause or GROUP BY of a statement AND has a data skew Relies on column usage information gathered at compilation time and stored in SYS.COL_USAGE$ Four types of histograms Frequency Top-Frequency Height balanced Hybrid 4 Oracle Confidential

Histograms Frequency Histograms (FREQUENCY) A frequency histogram is only created if the number of distinct values in a column (NDV) is less than 254 values Frequency histogram 5 Oracle Confidential

Histograms Top Frequency (TOP-FREQUENCY) Traditionally a frequency histogram is only created if NDV < 254 What if a small number of values occupies most of the rows (>99%)? Creating a frequency histograms on that small set of values is very useful even though NDV is greater than 254 Ignoring unpopular values allows for better quality histogram Built using the same technique used for frequency histograms Only created with AUTO_SAMPLE_SIZE 6

Top Frequency Histogram Example Table PRODUCT_SALES contains information on Christmas ornament sales TIME_ID column perfect candidate for top-frequency histogram It has 1.78 million rows There are 620 distinct TIME_IDs But 99.9% of the rows have less than 254 distinct TIME_IDs 7

Histograms Height Balanced Histograms (HEIGHT BALANCED) A height balanced histogram is created if the number of distinct values in a column (NDV) is greater than 254 values Height balanced histogram 8

Histograms Hybrid Histograms (HYBRID) A height balanced histogram is created if the number of distinct values in a column (NDV) is greater than 254 values Hybrid histogram 9

Histograms Hybrid Histograms (HYBRID) Similar to height balanced histogram as created if the NDV >254 Store the actual frequencies of bucket endpoints in histograms No values are allowed to spill over multiple buckets More endpoint values can be squeezed in a histogram Achieves the same effect as increasing the # of buckets Only created with AUTO_SAMPLE_SIZE 10

Height-balanced versus Hybrid Histogram Oracle Database 11g Oracle Database 12c 11

Height-balanced Histogram Example Step 1: SELECT row_num, time_id FROM sales ORDER BY 2; ROWNUM TIME_ID 1 02-JAN-98 2 03-JAN-98 3 05-JAN-98 4 05-JAN-98 5 06-JAN-98 6 09-JAN-98 7 09-JAN-98 8 09-JAN-98 9 10-JAN-98 10 10-JAN-98 : : With a traditional height based histogram an even number of rows goes in each bucket Multiple buckets can have the same endpoint There are 960 rows in the sales table Automatically created histograms have 254 buckets That is 3.77 rows per bucket 12

Height-balanced Histogram Example Step 2: Assign roughly an equal number of rows per bucket ROWNUM TIME_ID 1 02-JAN-98 2 03-JAN-98 3 05-JAN-98 4 05-JAN-98 5 06-JAN-98 6 09-JAN-98 7 09-JAN-98 8 09-JAN-98 9 10-JAN-98 10 10-JAN-98 : : Bucket 0 has end point 02-JAN-98 Bucket 1 has end point 05-JAN-98 Bucket 2 has end point 09-JAN-98 Step 3: Bucket 0 added for min value Step 4: Buckets with the same endpoint are compressed 13

Height-balance Histogram Example Multiple buckets have the same endpoint Max number of popular values that could have been recorded 96 Missing bucket numbers are buckets that have been compressed 14

Height-balanced versus Hybrid Histogram Oracle Database 11g Oracle Database 12c 15

Hybrid Histogram Example Step 1: SELECT row_num, time_id FROM sales ORDER BY 2; ROWNUM TIME_ID 1 02-JAN-98 2 03-JAN-98 3 05-JAN-98 4 05-JAN-98 5 06-JAN-98 6 09-JAN-98 7 09-JAN-98 8 09-JAN-98 9 10-JAN-98 10 10-JAN-98 : : As with traditional height based histogram want an even number of rows in each bucket But no two buckets have the same endpoint There are 960 rows in the sales table Automatically created histograms have 254 buckets That is 3.77 rows per bucket 16

Hybrid Histogram Example Step 2: Assign roughly an equal number of rows per bucket ROWNUM TIME_ID 1 02-JAN-98 2 03-JAN-98 3 05-JAN-98 4 05-JAN-98 5 06-JAN-98 6 09-JAN-98 7 09-JAN-98 8 09-JAN-98 9 10-JAN-98 10 10-JAN-98 : : Bucket 1 has end point 02-JAN-98 1 Bucket 5 has end point 06-JAN-98 1 Bucket 10 has end point 10-JAN-98 2 17

Hybrid Histogram Example No two buckets have the same endpoint Frequency of endpoint values recorded in new column called endpoint repeat count Potential to recorded 254 popular values : Frequency at which an endpoint values occurs in the sample is recorded You can manual increase the number of buckets to 2048 18

Online Statistics Gathering Statistics gathered as part of the direct path load operations Create Table As Select or Insert As Select commands Statistics available directly after load No additional table scan required to gather statistics All internal maintenance operations that use CTAS benefit from this Note only occurs on IAS if table is empty 19

Online Statistics Gathering Example New table SALES2 is created using a CTAS command Both table and column level statistics are available immediately after table has been created Statistics immediately available 20

Online Statistics Gathering Example Histogram & index statistics not gathered To gather these statistics without re-gathering basic statistics set option parameter of GATHER_TABLE_STATS to GATHER AUTO 21

Online Statistics Gathering Example Histogram & index statistics gathered using new GATHER AUTO option without regathering base column statistics 22

Session private statistics for GTT Overview Traditionally statistics gathered on GTT were shared by all sessions Share statistics are not always optimal Now each session can have its own version of statistics for GTT Controlled by new preference GLOBAL_TEMP_TABLE_STATS Default value is SESSION (non shared) To force sharing (as in 11g) set table preference to SHARED 23

Session private statistics for GTT Statistics gathered on a GTT are no longer shared by all sessions To restore shared statistics change the table preference GLOBAL_TEMP_TABLE_STATS to SHARED By default statistics on GGT are session-private 24

Enhanced Incremental Statistics Incremental statistics allows global level statistics to accurately generated from partition level statistics NDV statistics can now be accurately aggregated by the introduction of the synopsis The synopses are stored in the Sysaux tablespace In 12c reduced the space required to store synopses on disk 25

Enhanced Incremental Statistics NDV statistics can now be accurately aggregated The synopses are stored in the Sysaux tablespace 12c reduces the space required to store synopses on disk Sales Table May 18 th 2012 May 19 th 2012 May 20 th 2012 May 21 st 2012 May 22 nd 2012 1. Partition level stats are gathered & synopsis created 2. Global stats generated by aggregating partition level statistics and synopsis May 23 rd 2012 Sysaux Tablespace 26

Enhanced Incremental Statistics for Partition Exchange DBA 1. Create external table for flat files Sales Table May 18 th 2012 May 19 th 2012 May 20 th 2012 6. Global stats generated by aggregating partition level statistics for existing partition with stats on new partition 2. Use CTAS command to create non-partitioned table TMP_SALES May 21 st 2012 TMP_SALES 3. Set INCREMENTAL to true & INCREMENTAL_LEVEL to TABLE 4. Gather Statistics May 22 nd 2012 May 23 rd 2012 5. Alter table Sales exchange partition May_24_2012 with table tmp_sales May 24 th 2012 Sysaux Tablespace 27

Enhanced Incremental Statistics Staleness Tolerance During data load some rows going to the older partitions In 11g any DML on older partitions triggered partition statistics to be re-gathered Sales Table May 18 th 2012 May 19 th 2012 May 20 th 2012 May 21 st 2012 May 22 nd 2012 May 23 rd 2012 1. Partition level stats are gathered & synopsis created 2. Global stats generated by aggregating partition level statistics and synopsis Sysaux Tablespace 28

Enhanced Incremental Statistics Staleness Tolerance New DBMS_STATS preference INCREMENTAL_STALENESS When set to USE_STALE_PERCENT DML on less than 10% of rows in older partitions will not trigger re-gather Sales Table May 18 th 2012 May 19 th 2012 May 20 th 2012 May 21 st 2012 May 22 nd 2012 May 23 rd 2012 1. Partition level stats are gathered & synopsis created 2. Global stats generated by aggregating partition level statistics and synopsis Sysaux Tablespace 29

Statistics Enhancements Concurrent Statistics Gathering Original introduced in 11.2 Gather statistics on multiple objects at the same time Controlled by DBMS_STATS preference, CONCURRENT Uses Database Scheduler and Advanced Queuing Number of concurrent gather operations controlled by job_queue_processes parameter Each gather operation can still operate in parallel 30

Concurrent Statistics Gathering for SH Schema A statistics gathering job is created for each table and partition in the schema Level 1 contain statistics gathering jobs for all nonpartitioned tables and a coordinating job for each partitioned table Level 2 contain statistics gathering jobs for each partition in the partitioned tables Exec DBMS_STATS.GATHER_SCHEMA_STATS( SH ); 31

Concurrent Statistics Enhancements in 12c Multiple partitioned table support Batch manager to batch smaller jobs together to reduce scheduling over head Auto statistics gather job can now use concurrency Cap to limit the resource available to the job via resource manager 32

Extended Statistics Two types of Extended Statistics Column groups statistics Column group statistics useful when multiple column from the same table are used in where clause predicates or group by clause Expression statistics Expression statistics useful when a column is used as part of a complex expression in where clause predicate Automatically maintained when statistics are gathered on the table Candidates for columns groups can be manually or automatically determined 33

Automatic Column Group Detection Column groups detected based on an STS or by monitoring a workload Uses DBMS_STATS procedure SEED_COL_USAGE If the first two arguments are set to NULL the current workload will be monitored The third argument is the time limit in seconds 1. Start column group usage capture 34

Automatic Column Group Detection Actual number of rows returned by this query is 932 Optimizer under-estimates the cardinality as it assumes each where clause predicate will reduce number of rows returned Optimizer is not aware of real-world relations between city, state, & country 2. Run your workload 35

Automatic Column Group Detection Actual number of rows returned by this query is 145 Optimizer over-estimates the cardinality as it is not aware of the real-world relations between state & country 2. Run your workload 36

Automatic Column Group Detection SELECT dbms_stats.report_col_usage(user, 'customers') FROM dual; 3. Check column usage information recorded for our table EQ means column was used in equality predicate in query 1 COLUMN USAGE REPORT FOR SH.CUSTOMERS 1. COUNTRY_ID : EQ 2. CUST_CITY : EQ 3. CUST_STATE_PROVINCE : EQ 4. (CUST_CITY, CUST_STATE_PROVINCE, COUNTRY_ID) : FILTER 5. (CUST_STATE_PROVINCE, COUNTRY_ID) : GROUP_BY FILTER means columns used together as filter predicates rather than join etc. Comes from query 1 GROUP_BY columns used in group by expression in query 2 37

Automatic Column Group Detection 4. Create extended stats for customers based on usage SELECT dbms_stats.create_extended_stats(user, 'customers') FROM dual; EXTENSIONS FOR SH.CUSTOMERS 1. (CUST_CITY, CUST_STATE_PROVINCE, COUNTRY_ID): SYS_STUMZ$C3AIHLPBROI#SKA58H_N 2. (CUST_STATE_PROVINCE, COUNTRY_ID) : SYS_STU#S#WF25Z#QAHIHE#MOFFMM_ created created Column group statistics will now be automatically maintained every time you gather statistics on this table 38

END OF PART 3 39

40