Solved

How Oracle Optimizer chooses best plans?

Posted on 2014-03-04
2
364 Views
Last Modified: 2014-03-05
Hi,

I have following question related to oracle optimizer.

When a query is given to optimizer,
1. How it creates different plans without executing it.?
2. I believe only if the results are less than certain % of rows it uses index, for identifying this,
    it has to execute query right?

Please help me in understanding the above by giving some relevant examples or links.
0
Comment
Question by:sakthikumar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 74

Accepted Solution

by:
sdstuber earned 500 total points
ID: 39905505
1 - that's a huge question.
   If you really want to understand it I recommend reading Jonathan Lewis' book "Cost-Based Oracle Fundamentals"

As a quick list of some of the large factors-
the expected cardinalties of joins and filtering conditions
the availability of indexes, existence or absence of hints
the existence or absence of sql profiles
various init parameters
available temp space, memory and cpu
Parallel options on tables, indexes, partitions and subpartitions, etc.
ordering criteria
uniqueness



2 - no that is not correct.  Number of rows has almost nothing to do with it except incidentally.  Indexes are chosen based on the number anticipated blocks that will be read.  Of course, if you have few rows then the blocks will likely be smaller and if many rows the number of blocks will likely be larger; but the actual row count isn't particularly important.  It's the blocks.
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 39905699
yeah, huge question
1. basically it comes down to statistics
most of the items sdstuber indicates are gathered in statistics
based on those statistics the optimizer doesn't have to execute anything to build an execution plan

2. again ... statistics

the oracle performance tuning guide contains a few chapters, here is one
http://docs.oracle.com/cd/E11882_01/server.112/e10822/tdppt_sqltune.htm#TDPPT160
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question