What is index selectivity and why does it matter?
Answer
Selectivity measures how unique the values in an indexed column are — the ratio of distinct values to total rows. High selectivity (many distinct values, like email or UUID) means the index is very effective at narrowing down results quickly. Low selectivity (few distinct values, like a boolean is_active or a status column with 3 values) means the index returns a large fraction of rows — the query planner may choose a full table scan instead since following index pointers for 50% of rows is slower. Rule: indexes work best on high-cardinality columns. Index a low-selectivity column only in composite indexes where high-selectivity columns lead.
Previous
What are database constraints and what types exist?
Next
What is a self-join and when is it used?
More Database Design / Normalization Questions
View all →- Intermediate What are database anomalies and how does normalization prevent them?
- Intermediate What is denormalization and when is it used?
- Intermediate What are isolation levels in database transactions?
- Intermediate What are dirty reads, non-repeatable reads, and phantom reads?
- Intermediate What is query optimization and what is a query execution plan?