Giving the CBO what it craves: Input!

Slides:



Advertisements
Similar presentations
Tuning Oracle SQL The Basics of Efficient SQLThe Basics of Efficient SQL Common Sense Indexing The Optimizer –Making SQL Efficient Finding Problem Queries.
Advertisements

Introduction to SQL Tuning Brown Bag Three essential concepts.
Copyright © SoftTree Technologies, Inc. DB Tuning Expert.
Kurt Engeleiter Product Manager Database Manageability
Chapter 9. Performance Management Enterprise wide endeavor Research and ascertain all performance problems – not just DBMS Five factors influence DB performance.
SQL Server performance tuning basics
Overview of performance tuning strategies Oracle Performance Tuning Allan Young June 2008.
IO Waits Kyle Hailey #.2 Copyright 2006 Kyle Hailey Waits Covered in this Section  db file sequential read  db file scattered.
Exadata Distinctives Brown Bag New features for tuning Oracle database applications.
INTRODUCTION TO ORACLE Lynnwood Brown System Managers LLC Performance And Tuning – Lecture 7 Copyright System Managers LLC 2007 all rights reserved.
1. Aim High with Oracle Real World Performance Andrew Holdsworth Director Real World Performance Group Server Technologies.
External Sorting CS634 Lecture 10, Mar 5, 2014 Slides based on “Database Management Systems” 3 rd ed, Ramakrishnan and Gehrke.
CS 333 Introduction to Operating Systems Class 18 - File System Performance Jonathan Walpole Computer Science Portland State University.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 11 Database Performance Tuning and Query Optimization.
1 How to improve SQL Performance with new Health Check Tool? Carlos Sierra Consulting Technical Advisor © 2012 Oracle Corporation – Proprietary and Confidential.
Oracle 10g Database Administrator: Implementation and Administration
Oracle 11g Real Application Testing: Avoiding Performance Regressions with SQL Performance Analyzer Khaled Yagoub, Pete Belknap, Benoit Dageville, Karl.
Indexing Debapriyo Majumdar Information Retrieval – Spring 2015 Indian Statistical Institute Kolkata.
Executing Explain Plans and Explaining Execution Plans Craig Martin 01/20/2011.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
© 2006 IBM Corporation Adaptive Self-Tuning Memory in DB2 Adam Storm, Christian Garcia-Arellano, Sam Lightstone – IBM Toronto Lab Yixin Diao, M. Surendra.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Database Performance Tuning and Query Optimization.
Oracle Database Administration Lecture 6 Indexes, Optimizer, Hints.
1 Robert Wijnbelt Health Check your Database A Performance Tuning Methodology.
Physical Database Design & Performance. Optimizing for Query Performance For DBs with high retrieval traffic as compared to maintenance traffic, optimizing.
March 19981© Dennis Adams Associates Tuning Oracle: Key Considerations Dennis Adams 25 March 1998.
Improving Efficiency of I/O Bound Systems More Memory, Better Caching Newer and Faster Disk Drives Set Object Access (SETOBJACC) Reorganize (RGZPFM) w/
1 Chapter 7 Optimizing the Optimizer. 2 The Oracle Optimizer is… About query optimization Is a sophisticated set of algorithms Choosing the fastest approach.
1 Optimizing Your ColdFusion Applications for Oracle Justin Fidler, CNA, CPS, CCFD Chief Technology Officer Bantu, Inc. 8 May 2001.
Oracle Tuning Considerations. Agenda Why Tune ? Why Tune ? Ways to Improve Performance Ways to Improve Performance Hardware Hardware Software Software.
Persistent Systems Limited “Bhageerath”, 402, Senapati Bapat Road,Pune , Ph No: Santosh Kangane 1.
11-1 Improve response time of interactive programs. Improve batch throughput. To ensure scalability of applications load vs. performance. Reduce system.
1 Chapter 14 DML Tuning. 2 DML Performance Fundamentals DML Performance is affected by: – Efficiency of WHERE clause – Amount of index maintenance – Referential.
10/23/2015ISYS366 - Installation1 ISYS366 Installation.
CS4432: Database Systems II Query Processing- Part 2.
1 Chapter 13 Parallel SQL. 2 Understanding Parallel SQL Enables a SQL statement to be: – Split into multiple threads – Each thread processed simultaneously.
CS333 Intro to Operating Systems Jonathan Walpole.
10g Tuning Highlights Presenter JEREMY SCHNEIDER Senior Consultant, ITC Technology Services.
2010 Ami Levin. SQL Server implements three different physical operators to perform joins. In this session we will see how each of these three operators.
1 Chapter 9 Tuning Table Access. 2 Overview Improve performance of access to single table Explain access methods – Full Table Scan – Index – Partition-level.
Database Performance Eric Grancher - Nilo Segura Oracle Support Team IT/DES.
1 Chapter 8 Execution Plan Management. 2 Overview of Execution Plan Management Review techniques to – override optimizer – Improve optimizer’s decisions.
Copyright Sammamish Software Services All rights reserved. 1 Prog 140  SQL Server Performance Monitoring and Tuning.
An overview of AWR, ASH and ADDM. Learning About AWR Real-World Performance Day with Tom Kyte The Independent Oracle Users Groups presents “A Day of Real-World.
SQL Server Statistics DEMO SQL Server Statistics SREENI JULAKANTI,MCTS.MCITP,MCP. SQL SERVER Database Administration.
Same Plan Different Performance Mauro Pagano. Consultant/Developer/Analyst Oracle  Enkitec  Accenture DBPerf and SQL Tuning Training Tools (SQLT, SQLd360,
Exadata Distinctives 988 Bobby Durrett US Foods. What is Exadata? Complete Oracle database platform Disk storage system Unique to Exadata – intelligent.
This document is provided for informational purposes only and Microsoft makes no warranties, either express or implied, in this document. Information.
Tuning Oracle SQL The Basics of Efficient SQL Common Sense Indexing
Calgary Oracle User Group
Jonathan Walpole Computer Science Portland State University
Cleveland SQL Saturday Catch-All or Sometimes Queries
SQL Tuning.
EVOLUTION OF THE ORACLE OPTIMIZER THINKING
Database Performance Tuning &
Chapter 12: Query Processing
Database Performance Tuning and Query Optimization
Join Processing in Database Systems with Large Main Memories (part 2)
JULIE McLAIN-HARPER LINKEDIN: JM HARPER
Statistics: What are they and How do I use them
Troubleshooting Techniques(*)
Chapter 12 Query Processing (1)
Chapter 11 Database Performance Tuning and Query Optimization
Translation Buffers (TLB’s)
Introduction to Execution Plans
Introduction to the Optimizer
Translation Buffers (TLBs)
Introduction to Execution Plans
Review What are the advantages/disadvantages of pages versus segments?
Performance Tuning ETL Process
Presentation transcript:

Giving the CBO what it craves: Input! System Statistics Giving the CBO what it craves: Input!

Before 9i The magic sauce for tuning queries and aberrant CBO behavior was: OPTIMIZER_INDEX_COST_ADJ, OPTIMIZER_INDEX_CACHING Defaults were 0 for caching and 100 for index cost, indicating a 0% hit ratio on the buffer cache and that indexed access is 100% (exactly the same) as costly as full table scans. Awful defaults for OLTP systems DB_FILE_MULTIBLOCK_READ_COUNT also handy to help the CBO out.

9i Old OPTIMIZER parameters obsolete. Do not use. 9i and up: CBO uses the CPU Costing Model Lewis, Gorman, Kyte, Foote, Brietling, Geist and many, many more have all written about it. Cost = (#srds * sreadtm + #mrds * mreadtm + #cpucycles / cpuspeed) / sreadtm Let Oracle determine how costly IO operations are: memory, single vs. multiblock, etc. 9i Manual Had to ensure mreadtim was larger than sreadtim Can manually set them if gathering botches it

10g 10g Uses default NOWORKLOAD statistics upon DB startup if there are none (only gathers cpuspeednw): cpuspeednw: millions of operations per second ioseektim: disk seek time in milliseconds, default 10 iotfrspeed: disk transfer time in bytes per millisecond, default 4096 (most are faster than this) If workload stats aren’t gathered, Oracle does its best and calculates sreadtim, mreadtim and MBRC from NW stats: MBRC = db_file_multiblock_read_count | _db_file_optimizer_read_count [8] sreadtim = ioseektim + db_block_size/iotrfrspeed [12ms] mreadtim = ioseektim + db_file_multiblock_read_count * db_block_size/iotfrspeed [26ms] Can explicitly gather NOWORKLOAD stats to get real ioseektim and iotfrspeed measurements.

Which costing model in use? Can be seen at the end of tkprof output. 10g – CPU Costing by default 9i - CPU Costing if system statistics present Toggle off: optimizer_features_enable to low version _optimizer_cost_model NOCPU_COSTING hint

Maintain System Statistics Some OS bugs resulted in wacky values, in particular AIX had problems. So good idea to always check them after a gather. If wacky, manually set, ensuring mreadtim is some factor (2 to 4 times) larger than sreadtim to be semi-realistic. Good to regather after new hardware, disk, OS upgrade, Oracle upgrade, etc.

What do we have? Dev2 Before Fiddling Dev2 After Gather & Delete Dev2 After Gather of WORKLOAD Dev2 After Regather of NOWORKLOAD

What do we have? Statistics Retention MBRC SQL> EXEC dbms_output.put_line(dbms_stats.get_stats_history_retention); 31 PL/SQL procedure successfully completed MBRC SQL> show parameter multiblock NAME VALUE ------------------------------------ ------ db_file_multiblock_read_count 16

Jonathan Lewis If you haven't done anything to set the system statistics and have reset the db_file_multiblock_read_count, then Oracle uses a hidden parameter called _db_file_optimizer_read_count as the basis for calculating the cost of tablescans and index fast full scans. If you set the db_file_mulitblock_read_count, then the _db_file_optimizer_read_count copies the value. If you don't set the db_file_multiblock_read_count then the default for the _db_file_optimizer_read_count is eight.

Gathering NOWORKLOAD INTERVAL START/STOP EXEC dbms_stats.gather_system_stats(); OR EXEC dbms_stats.gather_system_stats('NOWORKLOAD'); INTERVAL EXEC dbms_stats.gather_system_stats('INTERVAL',360);--6hrs START/STOP EXEC dbms_stats.gather_system_stats('START'); -- time passes, can close session if you wish, later... EXEC dbms_stats.gather_system_stats('STOP');

Migration SQL for RCMD_ANSWER SELECT sr.enamem_id ,sr.scrphr_id AS phrase_id ,sr.scritmtyp_id AS item_type_id ,1 AS lang_id -- English for numerics and dates ,NULL AS answer_txt ,sr.scrres_answer_date AS answer_dt ,sr.scrres_answer_num AS answer_num FROM script_responses sr JOIN enabled_member_mstr em ON em.enamem_id = sr.enamem_id WHERE em.procstat_id < 14 AND em.enamem_home_unit_id > 0 AND (sr.scrphr_id <> 969 OR (sr.scrphr_id = 969 AND sr.scrres_answer_num IS NOT NULL)) AND (em.enamem_id <> 173563 OR (em.enamem_id = 173563 AND sr.scrphr_id <> 969)) AND (sr.scrres_answer_date IS NOT NULL OR sr.scrres_answer_num is NOT NULL) UNION SELECT srt.enamem_id ,srt.scrphr_id AS phrase_id ,srt.scritmtyp_id AS item_type_id ,srt.lang_id ,srt.restrans_answer_text AS answer_txt ,NULL AS answer_dt ,NULL AS answer_num FROM script_response_translations srt JOIN enabled_member_mstr em ON em.enamem_id = srt.enamem_id AND (srt.scrphr_id <> 969 OR (srt.scrphr_id = 969 AND srt.restrans_answer_text IS NOT NULL)) AND srt.restrans_answer_text IS NOT NULL;

Fixed SQL for RCMD_ANSWER SELECT /*+ FIRST_ROWS */ sr.enamem_id ,sr.scrphr_id AS phrase_id ,sr.scritmtyp_id AS item_type_id ,1 AS lang_id -- English for numerics and dates ,NULL AS answer_txt ,sr.scrres_answer_date AS answer_dt ,sr.scrres_answer_num AS answer_num FROM script_responses sr JOIN enabled_member_mstr em ON em.enamem_id = sr.enamem_id WHERE em.procstat_id < 14 AND em.enamem_home_unit_id > 0 AND (sr.scrphr_id <> 969 OR (sr.scrphr_id = 969 AND sr.scrres_answer_num IS NOT NULL)) AND (em.enamem_id <> 173563 OR (em.enamem_id = 173563 AND sr.scrphr_id <> 969)) AND (sr.scrres_answer_date IS NOT NULL OR sr.scrres_answer_num is NOT NULL) UNION ALL SELECT /*+ FIRST_ROWS */ srt.enamem_id ,srt.scrphr_id AS phrase_id ,srt.scritmtyp_id AS item_type_id ,srt.lang_id ,srt.restrans_answer_text AS answer_txt ,NULL AS answer_dt ,NULL AS answer_num FROM script_response_translations srt JOIN enabled_member_mstr em ON em.enamem_id = srt.enamem_id AND (srt.scrphr_id <> 969 OR (srt.scrphr_id = 969 AND srt.restrans_answer_text IS NOT NULL)) AND srt.restrans_answer_text IS NOT NULL;

Cost Comparison before System Stats UNION UNION ALL + FIRST_ROWS