Understanding the Cost Based OptimizerTITLE How the Cost Based Optimizer Impacts Performance TITLE Inside the Cost Based Optimizer: Data Points and Case StudiesTITLE Demystifying the Cost Based Optimizer Decision Making ProcessTITLE Optimizing Performance with the Cost Based Optimizer
This paper describes how the optimizer uses statistics and determines plans for executing SQL statement. It explains how the 10053 trace file can be used to understand Oracle's decisions on execution plans.
Similar to Understanding the Cost Based OptimizerTITLE How the Cost Based Optimizer Impacts Performance TITLE Inside the Cost Based Optimizer: Data Points and Case StudiesTITLE Demystifying the Cost Based Optimizer Decision Making ProcessTITLE Optimizing Performance with the Cost Based Optimizer
Similar to Understanding the Cost Based OptimizerTITLE How the Cost Based Optimizer Impacts Performance TITLE Inside the Cost Based Optimizer: Data Points and Case StudiesTITLE Demystifying the Cost Based Optimizer Decision Making ProcessTITLE Optimizing Performance with the Cost Based Optimizer (20)
Understanding the Cost Based OptimizerTITLE How the Cost Based Optimizer Impacts Performance TITLE Inside the Cost Based Optimizer: Data Points and Case StudiesTITLE Demystifying the Cost Based Optimizer Decision Making ProcessTITLE Optimizing Performance with the Cost Based Optimizer
1. Cost Based Optimizer – 1 of 2 Hotsos Enterprises, Ltd. Grapevine, Texas Oracle. Performance. Now. [email_address]
15. System Statistics Statistic Description sreadtim average time (ms) to complete a single block read mreadtim average time (ms) to complete a multi-block read cpuspeed average CPU cycles per second (in millions) cpuspeednw estimate of CPU cycles (v10) ioseektim estimate of average read seek time (v10) iotfrspeed estimate of transfer speed of I/O system (v10) mbrc average multiblock read count (in blocks) maxthr maximum I/O system throughput (in bytes/second) slavethr average slave I/O throughput (in bytes/second)
Note that without properly collected statistics, the CBO will do one of two things: if no statistics exist for any object used in the SQL statement, the CBO may use rule-based optimization (prior to v10) or use dynamic sampling if statistics exist for any single object but not others in the SQL statement, the CBO may use a set of default statistics for the object without statistics or use dynamic sampling. CBO default statistics for objects without collected stats (prior to v10…in v10 dynamic sampling is typically used instead of defaults): TABLE SETTING DEFAULT STATISTICS cardinality (number of blocks * (block size – cache layer) / average row length average row length 100 bytes number of blocks 100 or actual value based on the extent map remote cardinality (distrib) 2000 rows remote average row length 100 bytes INDEX SETTING DEFAULT STATISTICS levels 1 leaf blocks 25 leaf blocks/key 1 data blocks/key 1 distinct keys 100 clustering factor 800
Plot A illustrates a situation in which the execution plan does not change, but the query response time varies significantly as the number of rows in the table changes. This kind of thing occurs when an application chooses a TABLE ACCESS (FULL) execution plan for a growing table. It’s what causes RBO-based applications to appear fast in a small development environment, but then behave poorly in the production environment. Plot B illustrates the marginal improvement that’s achievable, for example, by distributing an inefficient application’s workload more uniformly across the disks in a disk array. Notice that the execution plan (or “shape of the performance curve”) isn’t necessarily changed by such an operation (although, if the output of dbms_stats.gather_system_statistics changes as a result of the configuration change, then the plan might change). The performance for a given number of rows might change, however, as the plot here indicates. Plot C illustrates what is commonly the most profound type of performance change: an execution plan change. This situation can be caused by a change to any of CBO inputs. For example, an accidental deletion of a segment’s statistics can change a plan from a nice fast plan (depicted by the green curve, which is O(log n)) to a horrifically slow plan (depicted by the red curve, which is O(n 2 )). The phenomenon illustrated in plot C is what has happened when a query that was fast last week now runs for 14 hours without completing before you finally give up and kill the session.