I'm quoting from Jonathan Lewis's book Cost-based Oracle Fundamentals which explains all and I would recommend to everyone, but here's a summary
'... the predicted number of rows(cardinality) generated by an operation plays a crucial part in selecting initial join orders and optimum choice of indexes...'
'...the optimizer's calculation of cardinality are based on estimating the expected fraction of the rows in the current data set that would pass a particular test. That fraction is the number we call the selectivity. After you've worked ou the selectivity, the cardinality is simply selectivity * (number of input rows).'
If a table has 1,000 rows and the optimizer expects that 10 of those rows will be selected as part of a query then "10" is the expected cardinality of the query and the selectivity is 10/1000 = 0.01.
Now i got clear idea about Selectivity & Cardinality.I've read some where,both these values helps in determining what percentage of rows that query will retrieve,based on this,the optimizer will decide whether to go for Index scan or Full table scan.Can you explain this scenario with a example?
Bookmarks