# When cardinality statistics are automatically updated

For the following operations that you perform on a table, Derby automatically creates statistics. Those operations are:

- (new index only) When you create a new index on an existing non-empty table.
- (new backing indexes only) When you add a primary key, unique, or foreign key constraint to an existing non-empty table.

For other operations, Derby automatically updates statistics for the table and all indexes on the table if they are already exist. Those operations are:

- (all indexes) When you execute SYSCS_UTIL.SYSCS_COMPRESS_TABLE.
- (index only) When you drop a column that is part of a table's index; the statistics for the affected index are dropped, and statistics for the other indexes on the table are updated.

Parent topic: Working with cardinality statistics
Related concepts
When cardinality statistics go stale