- 3,733,158 Users
- 2,246,705 Discussions
- 7,856,540 Comments

## Forum Stats

Discussions

#### Howdy, Stranger!

#### Categories

- 380.9K All Categories
- 2.1K Data
- 203 Big Data Appliance
- 1.9K Data Science
- 446.1K Databases
- 220.4K General Database Discussions
- 3.7K Java and JavaScript in the Database
- 22 Multilingual Engine
- 506 MySQL Community Space
- 459 NoSQL Database
- 7.7K Oracle Database Express Edition (XE)
- 2.8K ORDS, SODA & JSON in the Database
- 437 SQLcl
- 3.9K SQL Developer Data Modeler
- 185.4K SQL & PL/SQL
- 20.7K SQL Developer
- 291.2K Development
- 6 Developer Projects
- 116 Programming Languages
- 288K Development Tools
- 96 DevOps
- 3K QA/Testing
- 645.2K Java
- 16 Java Learning Subscription
- 36.9K Database Connectivity
- 148 Java Community Process
- 104 Java 25
- 22.1K Java APIs
- 137.7K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 12 Java Essentials
- 138 Java 8 Questions
- 85.9K Java Programming
- 79 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.2K Java SE
- 13.8K Java Security
- 195 Java User Groups
- 22 JavaScript - Nashorn
- Programs
- 177 LiveLabs
- 33 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 165 Deutsche Oracle Community
- 1.2K Español
- 1.9K Japanese
- 225 Portuguese

# Higtogram calculation

Hello Experts,

I am reading a white paper about CBO statistics the link is here. http://www.oracle.com/technetwork/database/focus-areas/bi-datawarehousing/twp-optimizer-stats-concepts-110711-1354477.

In the part of Frequency Histograms, in number 4. It gives a formula that how optimizer calculates the cardinality when use frequency histograms.

the Optimizer would first need to determine how many buckets in the histogram have 10 as their end point. It does this by finding the bucket whose endpoint is 10, bucket 503, and then subtracts the previous bucket number, bucket 483, 503 - 483 = 20.

After that the pharagraph continues like below

Then the cardinality estimate would be calculated using the following formula(number of bucket endpoints / total number of bucket) X NUM_ROWS, 20/503 X 503, so the number of rows in the PROMOTOINS table where PROMO_CATEGORY_ID =10 is 20.

My question is, when optimizer subtracts the previous bucket number from the intended bucket number. In that example, the result is 503 - 483 = 20. So, cant we already find the cardinality? I don't understand that why optimnizer needs the following formula? At least, can somebody explain why?

**(number of bucket endpoints / total number of bucket) X NUM_ROWS**

At the same time, If you look at Oracle documentation here Histograms

The end points show different location. For example, in white paper the end point and the value is same. However, in documents end point the the bucket number. Basicly the concept of histogram is very simple but documents make it confusing. **Please share your remarkable thoughts.**

Thanks in advance.