hive的存储格式
案例测试
案例一:textfile
案例二:sequencefile
案例三:parquet
rcfile 和 orcfile跟上述一样
stored as rcfile
stored as orcfile
hive的索引
概要
索引的创建
2 )创建索引
create index index_rate2
on table rate2(uid)
as 'compact' -- 索引文件的存储格式
with deferred rebuild -- 索引能够重建
;
3 ) 修改索引(重建索引) 目的产生索引文件
alter index index_rate2
on rate2 rebuild;
4 ) 查看索引
show index on rate2;
5 ) 验证性能
select count(*) from rate1;
select count(*) from rate2;
select * from rata1 where uid = 6040;
select * from rata2 where uid = 6040;
6 ) 创建联合索引
create index index_rate2_uid_movie
on table rata2(uid,movie)
as 'bitmap'
with deferred rebuild
;
alter index index_rate2_uid_movie on rate2 rebuild;
select * from rate1 where uid=6040 and movie=2020;
select * from rate2 where uid=6040 and movie=2020;
7 ) 删除索引
drop index index_rate2 on rate2;
hive的视图
hive的数据压缩
HQL语句最终会被编译成Hadoop的Mapreduce job,因此hive的压缩设置,实际上就是对底层MR在处理数据时的压缩设置。
hive在map阶段的压缩
map阶段的设置,就是在MapReduce的shuffle阶段对mapper产生的中间结果数据压缩。在这个阶段,优先选择一个低CPU开销的算法。
hive在reduce阶段的压缩
即对reduce阶段的输出数据进行压缩设置。
常用压缩格式
案例测试