I am reviewing and learning SQL, there is something that I notice that seems curious to me.
Suppose I have a table called productos
and one of its fields is categoria
, when doing the following queries I see that the result is the same:
SELECT DISTINCT categoria FROM productos;
Y
SELECT categoria FROM productos GROUP BY categoria;
The difference that I notice is that with DISTINCT
me it filters the duplicates and respects the order in which they appear, while with the sentence that it uses it GROUP BY
organizes them in alphabetical order. Based on that, it can be said that the first statement executes faster. If so, when handling large volumes of data, would the difference in performance be considerable?