DISTINCT and GROUP BY
For cases when the DISTINCT is semantically equivalent to GROUP BY, the optimizer makes a cost‑based decision to eliminate duplicates either by way of a combined sort and duplicate elimination or an aggregation step.
For cases when the DISTINCT is semantically equivalent to GROUP BY, the optimizer makes a cost‑based decision to eliminate duplicates either by way of a combined sort and duplicate elimination or an aggregation step.