hadoop - Hive 选择 - Fetch 和 MapReduce

标签 hadoop hive partitioning bucket

我有两张 table

  1. External Table A
  2. External Table B With paritioned and bucketed columns

Table A has 5 columns (lets say c1,c2,c3,c4,c5)

Table B has 5 columns (c1,c2,c3,c4 partitioned on c5 and buketed on c1.



我运行以下查询
1. select * from A where c5="x" and c1="y"
2. select c1,c2,c3 from A where c5="x" and c1="y"
3. select * from B where c5="x" and c1="y"
4. select c1,c2,c3 from B where c5="x" and c1="y"

所有这些都不使用MR但只是 fetch 运算符。

Q1:MR或 Fetch - 这是否取决于文件的大小或其相同的行为?

Q2:第 2 次和第 4 次查询的行为与 link 相矛盾。 .这是最近的改进吗?
5. select count(*) from A where c5="x" and c1="y"
6. select count(*) from B where c5="x" and c1="y"

Q3:显然这两个需要MR但 5 比 6 快两倍。理想情况下,6 应该更快,因为表 B 已分区和分桶,并且查询基于这些列。可能的原因是什么?我多次运行查询。

注意:我使用 HDP 2.3

最佳答案

关于第一季度和第二季度:

从版本 13 开始,最近对 hive 进行了升级,它使用 hive 表统计信息、列统计信息,就像将表存储为 ORC 时一样,即分析功能。这避免了对 count(*) 查询和所有查询执行 MR。您可以使用 show create table 语法检查表的表属性,您可以在其中看到表计数在添加记录等时更新。这些值也记录在配置单元元存储中。

引用 this , thisthis

Q3:

当我们处理小型数据集时,您提到的 MR 执行基准可能是正确的。分区表和分桶表对于小型数据集的性能可能不会更好,因为它必须经历整个 MR 阶段,这与非分区表和非分桶表不同。

希望我给了你一个关于你的查询的小要点。

关于hadoop - Hive 选择 - Fetch 和 MapReduce,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34732071/

相关文章:

mysql - 需要帮助选择正确的 mysql 数据库分片、集群或分区方法

hadoop - HIVE - "skip.footer.line.count"在 Impala 中不起作用

java - Hadoop FileSystem 应该关闭吗?

hadoop - 在 HIVE 中加载外部表时如何忽略括号

r - 列出 R 中的所有整数组合

apache-spark - 根据工作线程,内核和DataFrame大小确定Spark分区的最佳数量

hadoop - 区 block 大小效果Hadoop

java - 如何使用java代码设置hadoop tmp目录

sql - 需要将具有多个分隔符的列分隔为 Hive 中的多行

hadoop - 在 Impala 中使用 Hive UDF 在 Impala 1.2.4 中给出错误结果