To continue reading for free, register below or login
To read more you must become a member of SearchOracle.com
');
// -->

When you submit a query, Oracle often has multiple methods to execute the query. "Should I use an index or not? Which join method should I use?" Before Oracle can execute the query, it has to determine the answers to questions like these to determine an optimal execution path.
Older versions of Oracle used a set of rules to decide which execution path was the most "optimal." One rule said, if an index exists, use it. These rules were ranked, so some rules trumped other rules. All of this was called the rule-based optimizer (RBO).
Now think of a table with only two rows of data in it and an index on the table. It really doesn't make much sense to use the index when querying this table because doing so involves extra work. Just read the one block in the table containing the two rows and ignore the index. However, the old RBO would do the extra work because the RBO was not smart enough to understand that the table had so few rows so as to make the index inefficient. This concept brought us the cost-based optimizer (CBO). The CBO would make decisions based on the data distribution, the number of rows in the table, etc. The CBO needs information about the tables and indexes in order to make well-informed decisions. To help out the CBO, we calculate statistics on the tables and indexes that the CBO uses. The RBO does not use these statistics.
|