hive的四种文件存储格式的差异与优缺点

行式存储结构: TEXTFILE , SEQUENCEFILE 行式存储磁盘占用比较高

列式存储结构:ORC ,PARQUETFILE 列式存储磁盘占用比较低,

orc的压缩率最高 , parquet 压缩率最低
ZLIB SNAPPY

连接jdbc的hive命令:

beeline -u jdbc:hive2://hadoop161:10000 -n root 
set hive.server2.logging.opereation.level=none;

create table log_seqencefile(
uuid1 string, uuid2 string , uuid3 string , uuid4 string ,uuid5 string , 
uuid6 string
) row format delimited fields terminated by ',' stored as sequencefile : 行式存储(不压缩)


create table log_orc(
uuid1 string, uuid2 string , uuid3 string , uuid4 string ,uuid5 string , 
uuid6 string
) row format delimited fields terminated by ',' stored as orc 
tblproperites ("orc.compress"="none") ; 列式存储 (不压缩) 

数据插入情况

在插入数据的时候,需要先用textfile格式。

sequencefile 格式和ORC 格式

不能用 load data local inpath ‘/tmp/hive/log_uuid.csv’ into table log_orc; 导入 , 导入失败。

parquet 能导入,无法查询。只能用insert into table xxxx select * from log_textfile;(之前能成功导入和查询格式的表)

查看数据文件所占的大小的命令 :

dfs -du -h /user/hive/warehouse/log_textfile;

dfs output

26.2M 78.7M /user/hive/warehouse/log_textfile/log_uuid.csv |
可以看到 列式存储占的空间是1.4 到1.8兆。而行式存储占的空间为 26.2兆和27.8兆。
在这里插入图片描述

对列存储进行压缩是比较常见的。
两种压缩格式 ZLIB SNAPPY
在这里插入图片描述

stored as orc tblproperties(''orc.compress'='ZLIB');
stored as orc tblproperties(''orc.compress'='SNAPPY');
stored as parquet tblproperties(''orc.compress'='ZLIB');
stored as parquet tblproperties(''orc.compress'='SNAPPY');

在这里插入图片描述
发现orc中的ZLIB 压缩格式可以把数据从 1.8M 压缩到 232.5 KB 压缩率为 12.6%; (232.5/1.8*1024 )

压缩前后 查询速度其实差别不大;

hive的执行计划

在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值