美文网首页Hive在简书玩转大数据spark
Hive扩展功能(八)--表的索引

Hive扩展功能(八)--表的索引

作者: 咸鱼翻身记 | 来源:发表于2017-02-16 17:38 被阅读54次

软件环境:

linux系统: CentOS6.7
Hadoop版本: 2.6.5
zookeeper版本: 3.4.8

</br>

主机配置:

一共m1, m2, m3这三部机, 每部主机的用户名都为centos
192.168.179.201: m1 
192.168.179.202: m2 
192.168.179.203: m3 

m1: Zookeeper, Namenode, DataNode, ResourceManager, NodeManager, Master, Worker
m2: Zookeeper, Namenode, DataNode, ResourceManager, NodeManager, Worker
m3: Zookeeper, DataNode, NodeManager, Worker

资料

官方资料:
    https://cwiki.apache.org/confluence/display/Hive/IndexDev
    https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-Create/Drop/AlterIndex

</br>
</br>

一. 编辑hive-site.xml文件
<property>
    <name>hive.optimize.index.filter</name>
    <value>true</value>
</property>
<property>
    <name>hive.optimize.index.groupby</name>
    <value>true</value>
</property>
<property>
    <name>hive.index.compact.file.ignore.hdfs</name>
    <value>true</value>
</property>

</br>
</br>

二. 创建Hive表索引

官方资料:
    https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Indexing

1.创建/构造, 显示, 删除索引:
create index table01_index on table table01 (column2) as 'compact';
show index on table01;
drop index table01_index on table01;

2.创建时重构, 格式化显示 (with column names), 删除索引:
create index table02_index on table table02 (column3) as 'compact' with deferred rebuild;
alter index table02_index on table2 rebuild;
show formatted index on table02;
drop index table02_index on table02;

3.创建索引视图, 构建, 显示, 删除:
create index table03_index on table table03 (column4) as 'bitmap' with deferred rebuild;
alter index table03_index on table03 rebuild;
show formatted index on table03;
drop index table03_index on table03;
4.在新表中创建索引:
create index table04_index on table table04 (column5) as 'compact' with deferred rebuild in table table04_index_table;

5.创建索引以RCFile的存储格式:
create index table05_index on table table05 (column6) as 'compact' stored as RCFile;

6.创建索引以TextFile的存储格式:
create index table06_index on table table06 (column7) as 'compact' row format delimited fields terminated by '\t' stored as textFile;

7.创建索引和索引的属性:
create index table07_index on table table07 (column8) as 'COMPACT' idxproperties ("prop1"="value1", "prop2"="value2");

8.创建索引和表的属性:
create index table08_index on table table08 (column9) as 'compact' tblproperties ("prop3"="value3", "prop4"="value4");

9.索引如果存在则删除:
drop index if exists table09_index on table09;

10.重构一个分区的数据:
alter index table10_index on table10 partition (columnX='valueQ', columnY='valueR') rebuild;

</br>
</br>
</br>

相关文章

  • Hive扩展功能(八)--表的索引

    软件环境: 主机配置: 一共m1, m2, m3这三部机, 每部主机的用户名都为centos 资料 一. 编辑hi...

  • Hive-索引

    简介 Hive从0.7.0版本开始加入了索引,目的是提高Hive表指定列的查询速度。没有索引的时候,Hive在执行...

  • Hive 1.2.1 分区和分捅

    1. 借鉴 Hive学习笔记——Hive中的分桶Hive分区和分桶(0925)HIVE表索引,分区和分桶的区别 2...

  • Hive扩展功能(七)--Hive On Spark

    软件环境: 主机配置: 一共m1, m2, m3这三部机, 每部主机的用户名都为centos 参考资料: 说明: ...

  • Hive- UDF&GenericUDF

    hive udf简介 在Hive中,用户可以自定义一些函数,用于扩展HiveQL的功能,而这类函数叫做UDF(用户...

  • HIVE表索引,分区和分桶的区别

    1.索引    Hive支持索引,但是Hive的索引与关系型数据库中的索引并不相同,比如,Hive不支持主键或者外...

  • Hive扩展功能(一)--Parquet

    软件环境: 主机配置: 一共m1, m2, m3这三部机, 每部主机的用户名都为centos 资料: 注意: 1....

  • Hive-分区&分桶

    分区 简介 为了避免Hive每次查询都扫描整个文件,除了采用索引的方式外,还可以通过建立分区表。分区表是指在创建表...

  • 大数据开发之Hive篇13-Hive的索引

    备注:Hive 版本 2.1.1 一.Hive索引简介 Hive索引的目标是提高对表的某些列进行查询查找的速度。如...

  • oracle 常用指令

    oracle常用指令 表空间查询 查询表空间中对象的详细信息 重建索引 创建表空间 查询表文件是否自动扩展 优化表...

网友评论

    本文标题:Hive扩展功能(八)--表的索引

    本文链接:https://www.haomeiwen.com/subject/evehwttx.html