|< < 52 > >|

Estimating the cost of a plan

Table statistics

Estimating selectivity

select * from Employee where age between 65 and 70

Use the index or scan the table?

  • There are 710 employees.

  • between 65 and 70 is covered by the last two buckets.
    • Assuming uniform distribution within the 63-67 bucket, 65-67 is 3/5 of the bucket, so 19.2 Employees.
    • Similarly, 68-70 is 3/5 of the 68-72 bucket: 4.2
    • Total: 23.4

  • Selectivity is 23.4 / 710 = 3.3%.

OK to use an index up to 10% selectivity, so: Use the index

|< < 52 > >|