hive - Hive TEZ 需要很长时间来运行查询
问题描述
我对 Hive 和 Hadoop 有点陌生。我有一个查询需要 10 分钟才能完成查询。
数据大小为 10GB 统计信息:行数:4457541 数据大小:1854337449 基本统计信息:COMPLETE 列统计信息:COMPLETE
分区和分桶是在表中完成的。
如何改进以下查询。
select * fromtbl1 where clmn='Abdul' and loc='IND' and TO_UNIX_TIMESTAMP(ts) > (UNIX_TIMESTAMP() - 5*60*60);
set hive.vectorized.execution.reduce.enabled=true;
set hive.tez.container.size=8192;
set hive.fetch.task.conversion = none;
set mapred.compress.map.output=true;
set mapred.output.compress=true;
set hive.fetch.task.conversion=none;
-----------+--+
| Explain |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--+
| Plan not optimized by CBO. |
| |
| Stage-0 |
| Fetch Operator |
| limit:-1 |
| Stage-1 |
| Map 1 |
| File Output Operator [FS_2973] |
| compressed:false |
| Statistics:Num rows: 49528 Data size: 24516360 Basic stats: COMPLETE Column stats: COMPLETE |
| table:{"input format:":"org.apache.hadoop.mapred.TextInputFormat","output format:":"org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat","serde:":"org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe"} |
| Select Operator [SEL_2972] |
| outputColumnNames:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"] |
| Statistics:Num rows: 49528 Data size: 24516360 Basic stats: COMPLETE Column stats: COMPLETE |
| Filter Operator [FIL_2971] |
| predicate:((section = 'xysaa') and (to_unix_timestamp(ts) > (unix_timestamp() - 18000))) (type: boolean) |
| Statistics:Num rows: 49528 Data size: 24516360 Basic stats: COMPLETE Column stats: COMPLETE |
| TableScan [TS_2970] |
| ACID table:true |
| alias:pp |
| Statistics:Num rows: 4457541 Data size: 1854337449 Basic stats: COMPLETE Column stats: COMPLETE |
| |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--+
这些参数都没有帮助我们在更短的时间内解决查询。
解决方案
根据计划,查询在 mapper 上运行,未启用矢量化。尝试这个:
set hive.vectorized.execution.enabled = true;
set hive.vectorized.execution.reduce.enabled=true;
调整映射器并行度:
set tez.grouping.max-size=67108864;
set tez.grouping.min-size=32000000;
使用这些设置来增加正在运行的映射器的数量。理想情况下,它应该在没有此设置的情况下运行:
set hive.tez.container.size=8192;
另一项建议是替换unix_timestamp()
为UNIX_TIMESTAMP(current_timestamp)
. 此函数不是确定性的,并且它的值对于查询执行的范围也不是固定的,因此会阻止查询的适当优化 - 自 2.0 以来已弃用此函数,取而代之的是CURRENT_TIMESTAMP
常量。
(UNIX_TIMESTAMP(current_timestamp) - 5*60*60)
此外,您的文件非常小。分区大小为200-500,每个分区12个文件,20-50Mb是文件大小。幸运的是它是 ORC,您可以使用ALTER TABLE CONCATENATE COMMAND连接文件。12 个文件没什么大不了的,在查询单个分区时您可能不会注意到改进。
推荐阅读
- azure - Azure 应用服务 - 在 Jetty 上运行 Solr - Azure 维护后出现 LockObtainFailedException
- node.js - Node.js 错误 - AssertionError [ERR_ASSERTION]: 模式不应该使用全局或粘性模式...重新安装包后
- powerbi - powerBI 查找和子字符串
- java - SQSEvent 在 aws-lambda-java-events 1.x 中不存在并且 AmazonS3 在 aws-lambda-java-events 2.x 中不存在?
- r - R中的多个数据帧为空
- php - 从 url 获取 api json 数据
- javascript - 根据点击的元素触发不同的功能
- html - 页脚偏移中的数据表下拉列表
- html - 如何让两个垂直元素的高度之一取决于另一个?
- android - 如何使用 JDBC 驱动器将 MySql 表图像 (BLOB) 加载到 ImageView