使用TPC-H数据测试HIVE行存储及列存储的优劣
2011-08-15 09:54
851 查看
本文主要是测试了Hive中行存储和列存储(RCFile)之间的优劣。
1.TPCH
可以在http://www.tpc.org/tpch/ 获得源码,我下载的版本是2.14.0。
下载源码后,根据自己的系统修改makefile文件,比如我修改成如下形式:
CC =gcc
DATABASE= DB2
MACHINE = LINUX
WORKLOAD = TPCH
TPCH默认生成的数据格式是col1|col2|col3|,然而有的数据库的输入格式是col1|col2|col3,想要得到该种数据格式,修改tpch的源码dss.h文件:
/*#define PR_END(fp) fprintf(fp, "\n")*/ /* finish the record here */
#define PR_END(fp) {fseek(fp,-1,SEEK_CUR); fprintf(fp,"\n");}
然后makefile,则可以得到dbgen的可执行程序了。
使用./dbgen -h可以看到命令行的帮助信息。
2. HIVE
接下来说一下HIVE的配置。由于我想比较Hive中行存储数据及列存储数据的优劣,同时希望行列数据都是使用ZLIB压缩后的,因此需要修改一下Hadoop和Hive的配置。
Hadoop中需要修改的配置文件是mapred-site.xml:
1 #mapred-site.xml
2 <property>
3 <name>mapred.output.compression.type</name>
4 <value>BLOCK</value>
5 <description>If the job outputs are to compressed as SequenceFiles, how should
6 they be compressed? Should be one of NONE, RECORD or BLOCK.
7 Cloudera's Distribution for Hadoop switches this default to BLOCK
8 for better performance.
9 </description>
</property>
<property>
<name>mapred.output.compress</name>
<value>true</value>
</property>
<property>
<name>mapred.compress.map.output</name>
<value>true</value>
</property>
<property>
<name>mapred.output.compression.codec</name>
<value>org.apache.hadoop.io.compress.GZipCodec</value>
</property>
<property>
<name>mapred.map.output.compression.codec</name>
<value>org.apache.hadoop.io.compress.GZipCodec</value> </property>
同时Hive中也需要修改:
1 #hive-default.xml
2 <property>
3 <name>hive.exec.compress.output</name>
4 <value>true</value>
5 <description> This controls whether the final outputs of a query (to a local/hdfs file or a hive table) is compressed. The compression codec and other options are determined from hadoop config variables mapred.output.compress* </description>
6 </property>
7
8 <property>
9 <name>hive.exec.compress.intermediate</name>
<value>true</value>
<description> This controls whether intermediate files produced by hive between multiple map-reduce jobs are compressed. The compression codec and other options are determined from hadoop config variables mapred.output.compress* </description>
</property>
OK,配置好了,重启Hadoop,进入Hive,正式测试。
3.测试
加载100G TPC-H数据集的磁盘空间测试:
用于测试的SQL:
SELECT lineitem.returnflag, lineitem.linestatus, SUM (lineitem.extendedprice * (1-lineitem.discout)), AVG (lineitem.discout)
FROM lineitem
WHERE lineitem.shipdate <= '1998-11-28'
AND lineitem.orderkey > 1000
GROUP BY lineitem.returnflag,lineitem.linestatus; 测试结果
RCFile的查询比行式存储查询快的原因主要是在Map阶段,由于每个Map读入的数据量更小,IO开销小,因此能在更短的时间内完成Map。
4.总结
根据以上测试可见,RCFile的优势还是很大的,它在不降低查询性能的前提下比开源数据仓库系统(Hive)中的行存储技术节省磁盘存储空间。
1.TPCH
可以在http://www.tpc.org/tpch/ 获得源码,我下载的版本是2.14.0。
下载源码后,根据自己的系统修改makefile文件,比如我修改成如下形式:
CC =gcc
DATABASE= DB2
MACHINE = LINUX
WORKLOAD = TPCH
TPCH默认生成的数据格式是col1|col2|col3|,然而有的数据库的输入格式是col1|col2|col3,想要得到该种数据格式,修改tpch的源码dss.h文件:
/*#define PR_END(fp) fprintf(fp, "\n")*/ /* finish the record here */
#define PR_END(fp) {fseek(fp,-1,SEEK_CUR); fprintf(fp,"\n");}
然后makefile,则可以得到dbgen的可执行程序了。
使用./dbgen -h可以看到命令行的帮助信息。
2. HIVE
接下来说一下HIVE的配置。由于我想比较Hive中行存储数据及列存储数据的优劣,同时希望行列数据都是使用ZLIB压缩后的,因此需要修改一下Hadoop和Hive的配置。
Hadoop中需要修改的配置文件是mapred-site.xml:
1 #mapred-site.xml
2 <property>
3 <name>mapred.output.compression.type</name>
4 <value>BLOCK</value>
5 <description>If the job outputs are to compressed as SequenceFiles, how should
6 they be compressed? Should be one of NONE, RECORD or BLOCK.
7 Cloudera's Distribution for Hadoop switches this default to BLOCK
8 for better performance.
9 </description>
</property>
<property>
<name>mapred.output.compress</name>
<value>true</value>
</property>
<property>
<name>mapred.compress.map.output</name>
<value>true</value>
</property>
<property>
<name>mapred.output.compression.codec</name>
<value>org.apache.hadoop.io.compress.GZipCodec</value>
</property>
<property>
<name>mapred.map.output.compression.codec</name>
<value>org.apache.hadoop.io.compress.GZipCodec</value> </property>
同时Hive中也需要修改:
1 #hive-default.xml
2 <property>
3 <name>hive.exec.compress.output</name>
4 <value>true</value>
5 <description> This controls whether the final outputs of a query (to a local/hdfs file or a hive table) is compressed. The compression codec and other options are determined from hadoop config variables mapred.output.compress* </description>
6 </property>
7
8 <property>
9 <name>hive.exec.compress.intermediate</name>
<value>true</value>
<description> This controls whether intermediate files produced by hive between multiple map-reduce jobs are compressed. The compression codec and other options are determined from hadoop config variables mapred.output.compress* </description>
</property>
OK,配置好了,重启Hadoop,进入Hive,正式测试。
3.测试
加载100G TPC-H数据集的磁盘空间测试:
用于测试的SQL:
SELECT lineitem.returnflag, lineitem.linestatus, SUM (lineitem.extendedprice * (1-lineitem.discout)), AVG (lineitem.discout)
FROM lineitem
WHERE lineitem.shipdate <= '1998-11-28'
AND lineitem.orderkey > 1000
GROUP BY lineitem.returnflag,lineitem.linestatus; 测试结果
RCFile的查询比行式存储查询快的原因主要是在Map阶段,由于每个Map读入的数据量更小,IO开销小,因此能在更短的时间内完成Map。
4.总结
根据以上测试可见,RCFile的优势还是很大的,它在不降低查询性能的前提下比开源数据仓库系统(Hive)中的行存储技术节省磁盘存储空间。
相关文章推荐
- 使用tpc-ds生成测试数据过程
- 使用TPC-H对Hive测试
- mysql 使用 存储过程制造测试数据
- Hive数据导入方案—使用ORC格式存储hive数据
- 使用Spring的Property文件存储测试数据 - 初始化
- hive安装测试及Hive元数据的三种存储方式
- 使用mysql存储过程快速插入百万mysql测试数据
- Android学习总结二:五大布局、Android测试、数据存储访问(TextUtils)、Map的使用
- Hive简介、什么是Hive、为什么使用Hive、Hive的特点、Hive架构图、Hive基本组成、Hive与Hadoop的关系、Hive与传统数据库对比、Hive数据存储(来自学习资料)
- hive建表没使用LZO存储格式,可是数据是LZO格式时遇到的问题
- Android学习总结二:五大布局、Android测试、数据存储访问(TextUtils)、Map的使用
- 使用Spring的Property文件存储测试数据 - 编写测试和调用测试数据
- 使用TPC-H 对hive进行基准测试
- 使用Hive或Impala执行SQL语句,对存储在Elasticsearch中的数据操作(二)
- 使用Hive或Impala执行SQL语句,对存储在HBase中的数据操作
- hive安装测试及Hive 元数据的三种存储方式
- 使用Hive或Impala执行SQL语句,对存储在Elasticsearch中的数据操作
- 使用TPC-H对Hive测试
- 使用Spring的Property文件存储测试数据 - 添加测试数据
- Parquet_2. 在 Impala/Hive 中使用 Parquet 格式存储数据