开启Map输出阶段压缩
开启map输出阶段压缩可以减少job中map和Reduce task间数据传输量。具体配置如下:
set hive.exec.compress.intermediate=true;
set mapreduce.map.output.compress=true;
set mapreduce.map.output.compress.codec= org.apache.hadoop.io.compress.SnappyCodec;
select count(1) from score;
开启Reduce输出阶段压缩
属性hive.exec.compress.output控制着这个功能,用户可以通过在查询语句或执行脚本中设置这个值为true,来开启输出结果压缩功能。
set hive.exec.compress.output=true;
set mapreduce.output.fileoutputformat.compress=true;
set mapreduce.output.fileoutputformat.compress.codec = org.apache.hadoop.io.compress.SnappyCodec;
set mapreduce.output.fileoutputformat.compress.type=BLOCK;
insert overwrite local directory '/export/servers/snappy' select * from score distribute by s_id sort by s_id desc;