标签:index name create drop hive tbl ind 效率
问题描述:
使用hive时,drop表很慢,一张空表都需要90s左右
检查:
--------检查hive日志,无报错信息
--------检查主机资源消耗情况,正常无瓶颈
--------检查mysql日志,无错误提示
--------检查mysql慢日志(slow.log),发现在drop表时,会在元数据库中进行select,并且时间消耗接近于drop表的时间
问题分析:
1、hive在drop表的时候,会去元数据搜索到这张表,故需要进行select
2、通过explain检查select,发现有全表扫描记录,分析是没有添加相关索引
问题处理:
对元数据库的表添加相关索引,索引如下:
use hivedb;
create index ind_part_name_tbl_id on partitions(part_name,tbl_id);
create index ind_tbl_name on tbls (tbl_name);
create index ind_tbl_id on partitions (tbl_id);
create index ind_tbl_integer_idx on partition_keys (tbl_id,integer_idx);
create index ind_cd_integer_idx on columns_v2 (cd_id,integer_idx);
create index ind_name on dbs (name);
检查新增索引是否添加
show index from partitions;
show index from tbls;
show index from partition_keys;
show index from columns_v2;
show index from dbs;
重新drop测试结果:
通过建立的空表再drop时,时间只需不到3秒时间(所使用的库内有4.2W张表)
注:使用的库中表太多,对元数据查询还是有影响,故建议一个库不要存太多表
标签:index,name,create,drop,hive,tbl,ind,效率 来源: https://www.cnblogs.com/harda/p/15921117.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。