hive的索引:

hive的索引:


索引是數據庫的一種標準技術,hive在0.7版本以後支持索引,只不過hive的索引的性能要比關係型數據庫的差
優點:提高查詢效率,避免全表掃描
缺點:冗餘存儲,加載數據較慢
索引文件的特點:索引數據有序,並且數據量較小

 

索引的參數(關鍵字)index


如何創建一個索引

create table if not exists text3
as
select * from text2
;

 

create index id_idx
on table text3(uid)
as 'compact' //數據文件的存儲格式
with deferred rebuild//索引文件能夠重建
;

 

修改索引
 

alter index id_idx
on text3 rebuild
;

查看索引
 

show index on text3;

創建聯合索引
 

create index id_idx_uid_uname
on table text3(uid,uname)
as 'bitmap'
with deferred rebuild
;


select * from text2 where uid=95010 and uname like '%小濤';
select * from text3 where uid=95010 and uname like '%小濤';

刪除索引
 

drop index id_idx on text3;

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章