Database Indexing Basics and Access Patterns/Prefer high-selectivity columns

Columns with many distinct values tend to benefit more.

Section: Core concepts

Prefer high-selectivity columns

sql
sql
-- Better index candidate
WHERE email = ?

-- Often weaker candidate by itself
WHERE is_active = true
Explanation

An index on a highly selective column usually narrows results faster than an index on a low-cardinality flag.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Core concepts
What an index does
Indexes trade storage and write cost for faster reads.
OpenIn sheettextsame section
Remember the write cost
Every extra index must be maintained during inserts, updates, and deletes.
OpenIn sheettextsame section
Composite index left-prefix rule
Use column order that matches real filter patterns.
OpenIn sheetsqlsame section
Index joins and sorts too
Indexing is not just for filters.
OpenIn sheetsqlsame section
Index decision checklist
Use this checklist before creating a new index.
Measure with EXPLAIN before and after
Validate improvement instead of guessing.