《hive编程指南》阅读笔记摘要(七)

第8章 HiveQL:索引

1、hive只有有限的索引功能。

2、explain命令可以查看某个查询语句是否用到了索引

3、创建索引
create index employees_index
on table employees(country)
as 'org.apache.hadoop.hive.ql.index.compact.CompactIndexHandler'
with deferred rebuild
idxproperties('creator'='me', 'create_at' = 'some_time')
in table employees_index_table
partitioned by (country,name)
comment 'aaaaaaaaaaaaa';

(1)as...指定索引处理器

(2)with deferred rebuild   延迟重建索引,新索引是空的

(3)in table ... ,可以将索引保存在一张索引表里

(4)partitioned by,对原表中特定分区创建索引(即索引是分区级索引),如果没有这一句,对原表所有分区创建索引(索引是表级的索引)

4、Bitmap索引普遍应用于排重后值较少的列

5、重建索引
alter index employees_index
on table employees
partition(country='US')
rebuild;

6、显示索引
show formatted indexes on employees;

7、删除索引
drop index if exists employees_index on table employees;

(1)删除索引会连带删除对应的索引表

(2)删除原表,那么索引和索引表都会被删除

(3)删除原表的某个分区,那么这个分区对应的分区索引也同时被删除

*****************************
微信公众号:IT人成长关注
大数据技术QQ群:485681776

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值