Planner & statistics
Selectivity
Also called: filter fraction
Selectivity is the fraction of rows a condition is expected to keep, a number between 0 and 1. A selectivity of 0.01 means "this filter passes about 1% of the rows."
What this means
A fraction between 0 and 1 for how many rows a condition keeps. Selectivity 0.01 means "this filter passes roughly 1% of the rows." It's the planner's shorthand for how choosy a WHERE clause is, the lower the number, the more an index tends to pay off.
Why it matters operationally
Every plan decision, index versus sequential scan, join order, join method, is built on selectivity estimates. They are derived from the column statistics, so if the statistics are stale or skewed, selectivity is wrong, and the plan built on it is wrong.
Related & next
ANALYZE Internals, where selectivity numbers come fromMost Common Values, used for equality selectivityQuery planner, the consumer of selectivity