# Selectivity and cardinality statistics

The optimizer determines the number of rows that will be scanned from disk when deciding on an access path for a particular table (whether to use an index or to scan the table).

- The optimizer knows "exactly" the number of rows that will be scanned from disk for table scans (see Determinations of rows scanned from disk for a table scan).
- For index scans, the optimizer must estimate the number of rows that will be scanned from disk. (see Estimations of rows scanned from disk for an index scan). Derby might be able to use cardinality statistics to make a better estimate of the number of rows that will be scanned from disk as described in this chapter.

- Determinations of rows scanned from disk for a table scan
- Estimations of rows scanned from disk for an index scan
- Statistics-based versus hard-wired selectivity
- What are cardinality statistics?
- Working with cardinality statistics