前言:
由於工作中涉及數據更新操作,而hive on HDFS 實現更新比較麻煩,故想到了在hbase上建立hive外部表,然後通過impala進行查詢!下面是一組簡單的測試結果:
查詢數據量:2575656 53G
hive_hbase_news_info:hbase在hive中的映射表,記爲t1
hive_hbase_news_info_replic:hive中外部分區表,記爲t2
hive_hbase_news_info_u:優化後,hbase在hive中的映射表,記爲t3
查詢方式:Impala查詢
1.比較 count(1)
select count(1) from hive_hbase.hive_hbase_news_info;
select count(1) from hive_hbase.hive_hbase_news_info_replic;
次數 |
t1 |
t2 |
1 |
1m’34s |
12.12s |
2 |
1m’27s |
1.36s |
3 |
1m’24s |
1.28s |
優化後:
select count(1) from hive_hbase.hive_hbase_news_info_u;
次數 |
T3 |
1 |
89.42s |
2 |
62.66s |
3 |
55.98s |
4 |
53.38s |
2.比較 where+limit
select id,year from hive_hbase.hive_hbase_news_info where year = '2012' limit 100;
select id,year from hive_hbase.hive_hbase_news_info_replic where year = 2012 limit 100;
次數 |
t1 |
t2 |
1 |
13.02s |
0.14s |
2 |
12.87s |
0.14s |
3 |
12.99s |
0.14s |
優化後:
select id,year from hive_hbase.hive_hbase_news_info_u where year = '2012' limit 100;
次數 |
T3 |
1 |
20.42s |
2 |
20.43s |
3 |
20.15s |
select id,year from hive_hbase.hive_hbase_news_info where year = '2012' limit 1000;
select id,year from hive_hbase.hive_hbase_news_info_replic where year = 2012 limit 1000;
次數 |
t1 |
t2 |
1 |
21.64s |
0.20s |
2 |
21.35s |
0.20s |
3 |
21.46s |
0.20s |
優化後:
select id,year from hive_hbase.hive_hbase_news_info_u where year = '2012' limit 1000;
次數 |
T3 |
1 |
20.07s |
2 |
20.52s |
3 |
20.32s |
注:limit是很耗時的。
3.比較 where 大約23萬條
select id,year from hive_hbase.hive_hbase_news_info where year = '2012' ;
select id,year from hive_hbase.hive_hbase_news_info_replic where year = 2012 ;
次數 |
t1 |
t2 |
1 |
66.45s |
38.46s |
2 |
38.64s |
38.40s |
3 |
38.49s |
38.68s |
優化後:
select id,year from hive_hbase.hive_hbase_news_info_u where year = '2012' ;
次數 |
t1 |
1 |
39.46s |
2 |
39.50s |
3 |
39.47s |
4.比較 no where
select id,year from hive_hbase.hive_hbase_news_info ;
select id,year from hive_hbase.hive_hbase_news_info_replic ;
次數 |
t1 |
t2 |
1 |
171.91s |
175.26s |
2 |
171.77s |
172.94s |
優化後:
select id,year from hive_hbase.hive_hbase_news_info_u;
次數 |
T3 |
1 |
174.47s |
2 |
174.43s |
優化前後參數變化:
1.HBase RegionServer 的 Java 堆棧大小(字節):5G --> 10G
2.HBase 客戶端掃描儀緩存:
hbase.client.scanner.caching:100 --> 500
3.HBase 文件最大大小:
hbase.hregion.max.filesize:10G --> 5G
4.添加預分區
5.關閉mapreduce的推測執行:
mapred.map.tasks.speculative.execution --> false
mapred.reduce.tasks.speculative.execution --> false
好像優化後效果並不明顯,衰!
點擊“閱讀原文”查看網上一組測試結果!
本文分享自微信公衆號 - HBase工作筆記(HBase-Notes)。
如有侵權,請聯繫 [email protected] 刪除。
本文參與“OSC源創計劃”,歡迎正在閱讀的你也加入,一起分享。