group by 和 distinct 去重比较

distinct方式就是两两对比,需要遍历整个表。
group by分组类似先建立索引再查索引,所以两者对比,小表destinct快,不用建索引。大表group by快。一般来说小表就算建索引,也不会慢到哪去,但是如果是TB级大表,遍历简直就是灾难。
所以很多ORACLE项目都禁止使用distinct语句,全部要求替换成group by。

原文地址:https://www.cnblogs.com/wuer888/p/7521906.html