Is Group by Better Than Distinct

While DISTINCT better explains intent, and GROUP BY is only required when aggregations are present, they are interchangeable in many cases.

Which one is faster distinct or GROUP BY?

DISTINCT is much faster with large amount data. I tested this, and found that on an indexed column, mysql, group by was about 6x slower than distinct with a fairly complicated query.

Which is faster distinct or GROUP BY in hive?

In hive, however, the former only has one reduce task while the latter has many. From experiments, I founded that the GROUP BY is 10+ times faster than DISTINCT.

Alexander Ross

Alexander Ross

Gaming, Esports & Interactive Media Writer

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.

Share this article
Twitter Facebook Pinterest