hive:創建索引


hive也是支持索引的使用,但是如果表中已經有數據的情況下,創建索引的過程不是特別快。

已經擁有表:

create table if not exists llcfpd_withgroupbykey(groupbykey string,lrp string,timestamp string,objid string,uid string) 
row format delimited fields terminated by ',' stored as textfile;

創建索引:

create index idx_llcfpd_withgroupbykey on table llcfpd_withgroupbykey(groupbykey)
as 'org.apache.hadoop.hive.ql.index.compact.CompactIndexHandler' 
with deferred rebuild
IN TABLE llcfpd_withgroupbykey_idx;

備注:需要注意這里邊創建索引實際上是插入了特定的數據到一個表。

原表更新數據:

ALTER INDEX idx_llcfpd_withgroupbykey on llcfpd_withgroupbykey REBUILD;

備注:當表中已經擁有數據的情況下,必須執行該語句,否則索引沒有起到效果。

刪除索引:

DROP INDEX idx_llcfpd_withgroupbykey on llcfpd_withgroupbykey;

查看索引:

SHOW INDEX on llcfpd_withgroupbykey;

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM