在Where条件中使用变量时,Hive查询运行速度非常缓慢

编程入门 行业动态 更新时间:2024-10-27 18:21:54
本文介绍了在Where条件中使用变量时,Hive查询运行速度非常缓慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这是我的配置单元查询:

This is my hive query :

set s=date_add(from_unixtime(UNIX_TIMESTAMP()),-200); select * from a where dateString>=${hiveconf:s}

慢。出于某种原因,这种运行速度要快得多:

which runs very slowly. For some reason this runs much faster:

select * from a where dateString>='2015-01-01'

所以对于相同的日期值,第一个值要慢得多。为什么是这样?任何想法?

So with same date values the first one is much slower. Why is this? Any ideas?

推荐答案

指定分区时,不会发生动态分区修剪(除非使用Hive> = 0.14)。在where子句中指定精确值时,hive知道要扫描哪个分区。当从配置变量或另一个查询的结果中指定时,配置单元不知道要扫描的分区。 我建议使用Hive> = 0.14或通过用shell脚本替代hive conf来指定分区的确切值。

When specifying partitioning like that, dynamic partition pruning doesn't occur (unless using Hive >= 0.14). When specifying exact values in where clause, hive knows which partitions to scan. When specifying from config variables or from the result of another query, hive doesn't know which partitions to scan. I would suggest using Hive >= 0.14 or specifying the exact values of partitions by substituting variables by shell scripts instead of hive conf.

更多推荐

在Where条件中使用变量时,Hive查询运行速度非常缓慢

本文发布于:2023-11-16 23:44:03,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:变量   运行速度   缓慢   条件   Hive

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!