目录
Hive SQL优化
Hive表优化
1、分区
静态分区
动态分区
set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;
2、分桶
set hive.enforce.bucketing=true;
set hive.enforce.sorting=true;
Hive查询操作优化
1、join优化
hive.optimize.skewjoin=true;如果是join过程中出现倾斜 应该设置为true
set hive.skewjoin.key=100000; 这个是join的键对应的记录条数,超过这个值则会进行优化
2、map join
set hive.auto.convert.join=true;
hive.mapjoin.smalltable.filesize默认值是25mb
select /*+mapjoin(A)*/f.a, f.b from A t join B f on (f.a=t.a);
map join的使用场景:
- 关联操作中有一张表非常小
- 不等值的连接操作
3、bucket join
- 两个表以相同方式划分桶
- 两个表的桶个数是倍数关系
create table order(cid int, price float) clustered by(cid) into 32 buckets;
create table customer(id int, first string