hive中的distribute by, order by, sort by简述

    xiaoxiao2023-03-25  4

    order by

    大家都应该清楚,全局排序,但生成一个reducer,数据量大的时候会很慢。

    sort by

    在reducer段进行排序,只能保证每个reducer有序,不保证全局有序,单独使用的话,可用于求top n,如select col from table sort by xx limit 10,会产生两个job,第一个job求每个reducer的top n,第二个job求k个top n后即k*n个数据的top n(起一个reducer)。详细可以参考下: 这里

    distribute by

    主要用于分发,把相同的key发送到同一个reduce中,发完后不会对同一个reduce的key进行排序,通常与sort by一起使用,来保证通过reducer段的数据有序。
    转载请注明原文地址: https://ju.6miu.com/read-1203640.html
    最新回复(0)