1. 语法
explain [extended | dependency | authorization] query
2. 从执行计划中 可以获取那些信息?
1. Job任务的DAG(有向无环图)
2. 操作算子
示例 : Fetch Operator
Select Operator
Map Reduce
Map Operator Tree
Reduce Operator Tree
Group By Operator
3. Fetch Operator
说明: Hive 中针对单表的查询,可以不用使用MapReduce程序,而是使用Fetch 直接读取存储文件
4. 开启hive Fetch 转换
参数说明:
none : 不开启 fetch 转换参数(所有的单表查询,都会转换成mr)
minimal : 小粒度开启
转换条件 : 单表查询,where 只能为分区字段,limit
more : 开启
转换条件 : 单表查询,where 可以表的任意字段,limit
注意 : 默认为 more
方式1 : 修改配置文件 (默认开启)
1. 配置文件名称 : hive-default.xml.template
2. 修改项
<property>
<name>hive.fetch.task.conversion</name>
<value>more</value>
<description>
Expects one of [none, minimal, more].
Some select queries can be converted to single FETCH task minimizing latency.
Currently the query should be single sourced not having any subquery and should not have
any aggregations or distincts (which incurs RS), lateral views and joins.
0. none : disable hive.fetch.task.conversion
1. minimal : SELECT STAR, FILTER on partition columns, LIMIT only
2. more : SELECT, FILTER, LIMIT only (support TABLESAMPLE and virtual columns)
</description>
</property>
方式2 : 修改提交job参数 (会话级别)
1. 不开启对单表查询
set hive.fetch.task.conversion=none;
2. 小粒度开启
set hive.fetch.task.conversion=minimal;
3. 开启
set hive.fetch.task.conversion=more;
-- 测试
测试表 : 从1000w单表中 limit 111
none : 111 rows selected (23.842 seconds)
more : 111 rows selected (0.596 seconds)
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
· 【译】Visual Studio 中新的强大生产力特性
· 2025年我用 Compose 写了一个 Todo App