Solved

How Oracle Optimizer chooses best plans?

Posted on 2014-03-04
2
357 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
2 Comments
 
LVL 73

Accepted Solution

by:
sdstuber earned 500 total points
Comment Utility
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 36

Expert Comment

by:Geert Gruwez
Comment Utility
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Solar Winds Database performance Analyzer 2 74
null value 14 57
PL/SQL - Leading zeros 7 39
Oracle DATE Column Space 11 39
Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows how to recover a database from a user managed backup

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now