第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)删除原表,那么索引和索引表都会被删除
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