Presentation is loading. Please wait.

Presentation is loading. Please wait.

EVOLUTION OF THE ORACLE OPTIMIZER THINKING

Similar presentations


Presentation on theme: "EVOLUTION OF THE ORACLE OPTIMIZER THINKING"— Presentation transcript:

1 EVOLUTION OF THE ORACLE OPTIMIZER THINKING
Jurijs Velikanovs 7+ years Oracle DBA, OCP 7/8/8i/9i, OCA 9iAS R2

2 DEMO! Topics: Definition of database optimizer
Death of RBO or Why CBO is better Limitations of earlier CBO versions Some ways to workaround 8i + 9i Revolution DEMO!

3 About myself Introduction 8 years as Oracle DBA
Master degree in computer since 8 years as Oracle DBA OCP 7/8/8i/9i, OCA 9iAS R2 Oracle9i Database Administrator Certified Master 7+ in IT Alise First line Oracle support analyst Development DBA, Consultant DBA Teamleader

4 About IT Alise Introduction ~200 employees Main working directions
10+ years experience in Oracle development ~200 employees Main working directions Oracle Custom Development Oracle eBusiness Suite implementation Oracle Expert services

5 Definition of database optimizer

6 Definition of optimizer
Oracle9i Database Concepts “The optimizer determines the most efficient way to run a SQL statement.”

7 Definition of optimizer
Nowadays it means my opinion ”If application design reflects business needs you don’t have to think about particular SQL performance” I. Optimizer will find optimal path himself II. You still have to think about application design

8 Death of RBO ! or Why CBO is Better ?

9 DEMO! INDEX & RBO  tfc1/2/3.sql

10 Technically can’t choose optimal way
RBO Technically can’t choose optimal way Don’t know anything about data distribution There is set of rules You have to think about execution plan writing SQL Stabile life. SQL executes equally: yesterday/today/tomorrow RBO is dead  But what would say CBO? DEMO tfc2.sql

11 CBO How CBO found the way? Main Characteristics
DEMO event tfc4.sql PARAMETERS USED BY THE OPTIMIZER BASE STATISTICAL INFORMATION SINGLE TABLE ACCESS PATH OPTIMIZER STATISTICS AND COMPUTATIONS GENERAL PLANS Main Characteristics Works using statistics Looks through “all” possible paths Calculates COST and choose path with lowest cost There a lot of assumption

12 Limitations of earlier CBO versions

13 DB_FILE_MULTIBLOCK_READ_COUNT
FULL SCAN cost DEMO tfc4sql ‘adjusted’ multi-block read value for COST calculation number of blocks / aMBRC Some blocks can be in memory Don’t do MBR across extents Oracle don’t believe you (MBRC) All IO are equal Single block read = Multiblock read time

14 Limitations of earlier CBO (COST)
All IO are equal Single block read = Multiblock read time Think in PIO units LIO = PIO (buffer pool?) All Join operations speed are equal Full Scan = Nested Loop = Hash Join = Merge Join … All other operation ignored Comparization, Functions, …

15 Some ways to workaround 8i +

16 Some ways to workaround 8i +
Think in PIO units LIO = PIO (buffer pool?) OPTIMIZER_INDEX_CACHING (o_i_c) Measurement 0-100% Default value are far from real world = 0% How many blocks accessible via “db file sequential read” are in the cache 'buffer cache hit ratio'

17 Some ways to workaround 8i +
All IO are equal Single block read = Multiblock read time OPTIMIZER_INDEX_COST_ADJ (o_i_c_a) Measurement % Default value are far from real world = 100% “db file sequential read” cost * o_i_c_a = REAL COST “db file sequential reads” / ”db file scattered read” DEMO tfc5sql

18 Do not underestimate parameters impact
Conclusion 8i Do not underestimate parameters impact DB_FILE_MULTIBLOCK_READ_COUNT OPTIMIZER_INDEX_CACHING OPTIMIZER_INDEX_COST_ADJ Default values far from real world needs OPTIMIZER_INDEX_CACHING=0% OPTIMIZER_INDEX_COST_ADJ=100%

19 9i Revolution

20 9i Revolution = SYSTEM_STATS
Compute DBMS_STATS. GATHER_SYSTEM_STATS(gathering_mode => 'START'); DO THE LOAD … DBMS_STATS. GATHER_SYSTEM_STATS(gathering_mode => 'STOP'); Retrieve select * from sys.aux_stats$; DEMO ss.sql

21 Part 1: Multi block reads
Statistics computed SREADTIM: Average time for a single-block read request in milliseconds MREADTIM: Average time for a multi-block read request in milliseconds MBRC: Average number of blocks in a multi-block read. FullScan time = MREADTIM * BLOKS / MBRC Cost = FullScan time /SREADTIM Cost = Response time measured in single block reads DEMO tfc6.sql

22 Part 2: CPU Costing Model
Statistics computed CPUSPEED: Oracle calibration of system CPU speed Costing formula (Oracle9i Database Performance Tuning Guide and Reference) : COST = ( #SRds * SREADTIM + #MRds * MREADTIM + #CPUCycles / CPUSPEED ) / SREADTIM CPUCycles Virtually every operation have cost in terms of CPU usage HASH/SORT/PREDICATES SEARCH/IRS/IUS/TFS... There is internal Oracle table for operation calibration Model allows measure CPU usage DEMO ss1.sql

23 Conclusion It is really REVOLUTION! RBO is dead !!! The CBO keeps evolving Statistics & Parameters are essential Lot of wrong assumptions in earlier versions 9i+ revolutionary switch SYS_STATs There are still assumptions Design is most important! And now you can have time for design!

24 Jurijs Velikanovs Q&A +371-9268222 J.Velikanovs@alise.lv

25

26 Show Time @testsort @test_b1 @test_b2 @test_b3 @test_b4


Download ppt "EVOLUTION OF THE ORACLE OPTIMIZER THINKING"

Similar presentations


Ads by Google