# Selectivity from cardinality statistics

Cardinality statistics are computed by the Derby system and stored in the system tables.

For information on when these statistics get created or updated, see When cardinality statistics are automatically updated.

Derby can use cardinality statistics if all of the following are true:

- The statistics exist.
- The relevant columns in the WHERE column are leading columns in an index.
- The columns are compared to values using only the `=` operator.
- Statistics are not turned off in the system or query.

Parent topic: Statistics-based versus hard-wired selectivity
Related concepts
Selectivity from hard-wired assumptions