Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Predicate selectivity formula

unknown-879931Jun 6 2014 — edited Jun 6 2014

Hello Experts,

As far as I know the selectivity has only one formula which is the following without the usage of histograms.

Selectivity = 1 / NDV (number of ditinct values)

As far as I learned that the above formula only use for equality predicates, right?  For ex.: SELECT ... FROM TABLE WHERE COL = 'A';

When the following will be issued, will the selectivity formula change? Because I learned a new thing called range selectivity formula in Wolfgang Breitling paper.

SELECT ... FROM TABLE WHERE COL BETWEEN 'C' AND 'L';

Also what happen if more than one predicate performed?  Like WHERE col1 = 'A' and (col2 = 14 or col3 = 'Italy' );

 

Are the followings correct? If so, how can I use them?

 

selectivity(predicate1 AND predicate2) = selectivity(predicate1) * selectivity(predicate2).

selectivity(predicate1 OR predicate2) = selectivity(predicate1) + selectivity(predicate2) - selectivity(predicate1 AND predicate2)

I have just read the Fallacies of the Cost Based Optimizer - Wolfgang Breitling paper.

I mean, what are the selectivity formulas for different cases? Where can I learn clearly? I did not find this information in Oracle docs.

Regards

Charlie

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 4 2014
Added on Jun 6 2014
2 comments
1,098 views