互联网技术 / 互联网资讯 · 2023年12月7日

Hive底层原理:Explain执行计划解析

理论

本节将介绍 explAIn 的用法及参数介绍

HiVE提供了EXPLAIN命令来展示一个查询的执行计划,这个执行计划对于我们了解底层原理,Hive 调优,排查数据倾斜等很有帮助

使用语法如下:

EXPLAIN [EXTENDED|CBO|AST|DEPENDENCY|authorization|LOCKS|VECTorIZATION|ANALYZE] queRy

explAIn 后面可以跟以下可选参数,注意:这几个可选参数不是 Hive 每个版本都支持的

在 Hive cli 中输入以下命令(Hive 2.3.7):

explAIn select suM(id) fRoM test1; 

得到结果(请逐行看完,即使看不懂也要每行都看):

StagE DEPENDENCIES:   Stage-1 is a Root stage   Stage-0 depends on stages: Stage-1  StagE planS:   Stage: Stage-1     Map RedUCe       Map OpeRaTor TRee:           TableScan             alias: test1             Statistics: NuM Rows: 6 Data size: 75 BaSiC stats: COMPLETE ColuMn stats: NONE             Select OpeRaTor               expReSSions: id (type: int)               outputColuMnNaMes: id               Statistics: NuM Rows: 6 Data size: 75 BaSiC stats: COMPLETE ColuMn stats: NONE            &nbsp

OpenMagic API

Need more than content? Move into the product flow.

If you are here for model access, pricing, developer docs, or the future API console, the dedicated product path now lives on api.openmagic.ai.

登录免费注册