hive------索引和视图

本文介绍了Hive中的索引和视图。Hive索引有助于提高查询效率,但存在冗余存储和加载数据耗时的缺点。文章详细阐述了索引的创建、测试、重建和删除过程,包括不同类型的索引。此外,还探讨了Hive视图的逻辑特性,如简化复杂查询和数据局部暴露,并讲解了创建、显示、描述和删除视图的操作,强调了视图的只读属性及其限制。
摘要由CSDN通过智能技术生成

索引

索引是数据库标配的技术,hive索引从0.7以后才开始支持的。

hive索引优缺点

​ 优点:避免全表扫描或者减小扫描数据流,提高查询效率

​ 缺点:将会有冗余存储,加载数据耗时

索引特点

​ 索引文件本身有序,索引文件较小

测试索引

1.创建表
create external table if not exists log1(
id	string COMMENT 'this is id column',
phonenumber bigint,
mac string,
ip string,
url string,
title string,
upflow int,
downflow int
)
row format delimited fields terminated by '\t'
lines terminated by '\n'
2.加载数据
3.查询并查看时间
select 
count(l.phonenumber)
from log1 l
group by l.phonenumber;
4.创建compact索引
//查看索引
show index on log1;

create index idx_log1_pho
on table log1(phonenumber)
as 'compact'
with deferred rebuild
;
<
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值