selectivity
How small a fraction of rows a condition matches: a highly selective condition matches few rows.
In more detail
An index pays off when the condition is selective, such as one customer's orders. A condition that matches most rows, such as a status that is almost always paid, may be faster to answer with a scan, so an index on it may not be worth its cost.
Related terms
- index — A separate, sorted structure a database keeps alongside a table so it can find matching rows without reading them all.
- query planner — The part of the database that turns a SQL query into a plan, choosing among indexes, scans and join orders.
- table scan — Reading every row of a table to find the ones that match, instead of jumping to them through an index.
Taught in
- Cross Joins And Cartesian Bugs — PostgreSQL, Indexing & Relational Data Modeling
- Indexes And What They Cost — PostgreSQL, Indexing & Relational Data Modeling