Skip to Main Content

Oracle Database Discussions

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!

How does the CBO calculate the selectivity for range predicates on ROWID ?

Ahmed AANGOURAug 31 2010 — edited Sep 6 2010
Hi all,

I'm wondering how the CBO estimate the selectivity for range predicates based on ROWID columns.
For example, for the following query the CBO estimates there's going to be 35004 rows returned instead of 7:
SQL> SELECT count(*)
  FROM intsfi i
 WHERE
 ROWID>='AAADxyAAWAAHDLIAAB' AND ROWID<='AAADxyAAWAAHDLIAAH';  2    3    4

  COUNT(*)
----------
         7

Elapsed: 00:00:02.31
SQL> select * from table(dbms_xplan.display_cursor(null,null,'iostats last'));

PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID  aqbdu2p2t6w0z, child number 1
-------------------------------------
SELECT count(*)   FROM intsfi i  WHERE  ROWID>='AAADxyAAWAAHDLIAAB' AND
ROWID<='AAADxyAAWAAHDLIAAH'

Plan hash value: 1610739540

-------------------------------------------------------------------------------------------
| Id  | Operation             | Name    | Starts | E-Rows | A-Rows |   A-Time   | Buffers |
-------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT      |         |      1 |        |      1 |00:00:02.31 |   68351 |
|   1 |  SORT AGGREGATE       |         |      1 |      1 |      1 |00:00:02.31 |   68351 |
|*  2 |   INDEX FAST FULL SCAN| INTSFI2 |      1 |  35004 |      7 |00:00:02.31 |   68351 |
-------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter((ROWID>='AAADxyAAWAAHDLIAAB' AND ROWID<='AAADxyAAWAAHDLIAAH'))
According to Jonathan Lewis' book, for a normal column the selectivity would have been:
(value_column1-value_column2)/(high_value-low_value)+1/num_distinct+1/num_distinct

But here with the ROWID column, how does the CBO make its computation ?
SINGLE TABLE ACCESS PATH
  Single Table Cardinality Estimation for INTSFI[I]
  Table: INTSFI  Alias: I
    Card: Original: 14001681.000000  Rounded: 35004  Computed: 35004.20  Non Adjusted: 35004.20
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 4 2010
Added on Aug 31 2010
19 comments
2,173 views