Home > Ask the Oracle Database / Applications Experts > Oracle database backup and recovery Questions & Answers > Difference between RBO and CBO
Ask The Oracle Expert: Questions & Answers
EMAIL THIS

Difference between RBO and CBO

Brian Peasland1 EXPERT RESPONSE FROM: Brian Peasland1

Pose a Question
Other Oracle Categories
Meet all Oracle Experts
Become an Expert for this site


Oracle tips, scripts, and expert advice
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


>
QUESTION POSED ON: 02 December 2005
I do not have a clear idea about SQL tuning (Rule Based vs. Cost Based Optimizer). Could you explain the difference between RBO and CBO?

>

SQL statement tuning and the differences between RBO and CBO is quite a topic. Hopefully, the following will get you started. But more study will be necessary as this is only a cursory glance at the subject.

Whenever Oracle receives a SQL statement, it must decide the best manner in which to retrieve the data from the database. It is the job of the Optimizer to determine the most efficient method to use. There could be many different access paths to the data. In the earliest versions of Oracle, the Optimizer used a set of rules (RBO) to decide how to execute a given SQL statement. One rule stated than an index would be used in favor of a full table scan. So let's look at an example table of employees:

EMP
--------------------
ID     NUMBER  PRIMARY KEY
NAME   VARCHAR2(30)
GENDER CHAR(1)
On the EMP table, I have an index on the ID column and an index on the GENDER column. Since the ID is unique, querying for a specific ID can be most often facilitated by using the index. The Rule Based Optimizer (RBO) would always use this index to perform the query. Now let's query the same table for all females (GENDER='F'). The RBO, using the same rule, would use the index on this column to execute the query. Assuming equal distribution, the same number of men and women in the company, an index would be less effecient than simply scanning the entire table. Let's further assume that this table only has five rows of data that all fit comfortably in one database block, which requires only one I/O operation to read. Reading an index block, even for the ID column, would be more inefficient than performing a full table scan. SQL statement tuning when using RBO came down to the DBA obtaining an understanding of the data distribution and determining the best access path not found according to the RBO. The DBA would then rewrite the SQL statement to use the rule the DBA determined was most efficient.

The RBO has its share of problems as the above examples show. The RBO did not take into account data distribution or the size of the table. The Cost Based Optimizer (CBO) uses this type of information to make better informed decisions. The CBO needs statistics to be able to make informed decisions on the quickest access paths. SQL statement tuning under the CBO involves making sure that the correct statistics are in place, and even locking down statistics so that changes to the data do not affect the SQL statement processing. Additionally, the DBA can make use of Stored Outlines so as to get the same consistent access path for the queries. The DBA can still use SQL hints to influence the CBO as well, similar to the RBO.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google



RELATED CONTENT
Oracle database backup and recovery
How to perform Oracle database recovery with a corrupt online redo log
Can I create an Oracle Catalog Database with the Enterprise Console?
Do I need to recreate views after an Oracle table reorg?
Client-based apps vs. web-based apps in Developer 2000
How to perform an Oracle 8i to 10g migration
Can I move the tablespace online with missing datafiles in Oracle?
Oracle upgrade process vs. Oracle exp/imp for 9i to 10g migration
How to use RMAN CONVERT to migrate from Solaris to Oracle 11g RHEL
Why am I having trouble installing Oracle 10g on Vista?
Can I load Oracle 8 on Windows Server 2003?

Oracle database backup and recovery
How to perform Oracle database recovery with a corrupt online redo log
Can I create an Oracle Catalog Database with the Enterprise Console?
Do I need to recreate views after an Oracle table reorg?
Client-based apps vs. web-based apps in Developer 2000
Can I move the tablespace online with missing datafiles in Oracle?
How to perform an Oracle 8i to 10g migration
Oracle upgrade process vs. Oracle exp/imp for 9i to 10g migration
How to use RMAN CONVERT to migrate from Solaris to Oracle 11g RHEL
Why am I having trouble installing Oracle 10g on Vista?
Can I load Oracle 8 on Windows Server 2003?
Oracle database backup and recovery Research

Oracle and SQL
Can I specify Oracle column order in my database table?
Review: Oracle's 11g R2 database has some good and bad
SELECT statement syntax and examples
Oracle PL/SQL tutorial
PL/SQL datatypes in Oracle
PL/SQL functions and triggers in Oracle
Stored procedures in PL/SQL
Do I need a license for SQL Developer Data Modeler in Oracle?
Using the SQL GROUP BY clause for counting combinations
How to use an SQL CASE expression
Oracle and SQL Research

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
autonomous transaction  (SearchOracle.com)
CFML  (SearchOracle.com)
dynamic SQL  (SearchOracle.com)
foreign key  (SearchOracle.com)
Java Database Connectivity  (SearchOracle.com)
Open Database Connectivity  (SearchOracle.com)
Oracle  (SearchOracle.com)
stored procedure  (SearchOracle.com)
The Open Group  (SearchOracle.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



Oracle White Papers: Fusion Middleware
HomeNewsTopicsTipsAsk the ExpertsMultimediaWhite PapersProductsBlogs
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2003 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts