DISTINCT & ALL: Performance
Module: Aggregate Functions & Grouping
**Performance Tips:**
- DISTINCT requires sorting or hashing (expensive)
- Index columns used in DISTINCT
- Avoid DISTINCT on large result sets
- Use GROUP BY instead when aggregating
- Consider if duplicates are data quality issue
DISTINCT requires sorting or hashing (expensive)
Index columns in DISTINCT clause
Avoid DISTINCT on large result sets
Use GROUP BY for complex aggregations
Consider EXISTS instead of DISTINCT in subqueries
Using DISTINCT to hide data quality issues
Applying DISTINCT unnecessarily (performance cost)
Expecting DISTINCT on one column when selecting multiple
Not understanding DISTINCT with NULL values
Using DISTINCT when GROUP BY more appropriate