Postgres SELECT DISTINCT Does Not Scale
Deep dive 5 min +50 XP
Postgres SELECT DISTINCT always scans every index entry matching its predicates, so its cost grows with total matching rows rather than with the number of distinct values.
Postgres SELECT DISTINCT always scans every index entry matching its predicates, so its cost grows with total matching rows rather than with the number of distinct values.