Use group by instead of distinct
natejgardner
Neuron, Registered, Neuron 2022, Neuron 2023 Posts: 151 Neuron
Several recipes conveniently provide the ability to select distinct on their outputs, but this is highly inefficient in most databases. The same result can usually be achieved much faster by grouping by all the columns. Ideally, when the distinct option is selected in recipes, the resulting sql will prefer group by to distinct, at least in databases where group by is strictly better.
Tagged: