Oracle Scratchpad

Cost Based Optimisation

Back to main Tutorial Page

Understanding and Assisting the Cost Based Optimizer – Agenda

Is there a go_faster parameter ? Which parameters affect the Cost Based Optimizer (CBO) most? Just how does Oracle decide whether or not to use an index? Why does Oracle do a Hash Join instead of a Nested Loop? Why is Oracle ignoring my hints?

All these, and many other questions about the working of the Cost Based Optimizer will be answered by this tutorial.

Session 1
1.5 hours

Why isn’t Oracle using my index?

In this session we aim to acquire a visual, rather than highly mathematical, understanding of when Oracle will ignore an index. We start with a discussion of the strategic direction that we should be going with the cost based optimizer and then examine a simple example to pin-point the traditional reasons why the cost based optimizer in versions prior to 9.0 could so easily produce inappropriate execution plans. We examine a couple of commonly used tuning parameters which give Oracle better information about our system and allow it to identify the appropriate execution path more frequently, identifying the risks of using these parameters too extravagantly, and end with a demonstration of how using CPU costing solves the traditional problems with much less risk of error.

Break – coffee and informal discussion: 30 minutes
Session 2

1.5 hours

Mechanisms of Joins

We start by asking why it is so important to examine and understand join mechanisms and examine some of the transformations that convert complex queries to simple join forms. Then we look at details (and anomalies) of the nested loop, sort-merge, and hash joins; identifying strengths, weaknesses, and costs of each in turn. In the case of sort-merge and hash joins, we examine trace events, and their output, that allow us to investigate what is happening when response times become extreme.

Break – Lunch and informal discussion: 1 hour
Session 3

1.5 hours

Selectivity, Joins, and Hints

In this session we move on from the simple example of the first session to investigate what happens in the more general cases of using an index. We extend the arithmetic to the calculations involved in joining tables, and note some of the anomalies and problems that joins can cause. Finally we ask the question “What is a hint?” and try to answer the question by examining what really happens inside the optimizer when we start adding hints to our SQL.

Break – coffee and informal discussion: 30 minutes
Session 4

1.5 hours

Maximising the Truth

If there is any information we can give the optimizer about our data, we should do so; otherwise it will be less able to produce the appropriate execution.

We start this session by showing how a little extra information can help the optimizer find new execution paths. Then we examine the optimizer’s dependence on statistics, and its need to get a correct numeric representation of your data. We move on to see how strange data patterns, and bad database design, can stop the optimizer from choosing a sensible execution path, and end with a couple of techniques for encouraging the optimizer to do what we want.

 

Back to main Tutorial Page

Leave a Comment »

No comments yet.

RSS feed for comments on this post.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Rubric Theme. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 3,905 other followers