for the simplest case we all refer to:
select id from mytbl
group by id
and
select distinct id from mytbl
as we know, they generate same query plan which had been repeatedly mentioned in some items like Which is better: Distinct or Group By
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.
They are different.
So what I learned is:
GROUP-BY is anyway not worse than DISTINCT, and it is better sometimes.
I would like to know:
1. If this conclusion is true.
2. If true, I shall consider DISTINCT as a approach for logical convenience, but why DISTINCT doesn't take GROUP-BY's better implementation?
3. If false, I would be very eager to know its decent usage under big-data situation.
Thank you very much!!:)