HiveTez运行查询需要很长时间

uurity8g  于 2021-06-27  发布在  Hive
关注(0)|答案(1)|浏览(383)

我对hive和hadoop还不太熟悉。我有一个查询需要10分钟才能完成。
数据大小为10gb/statistics:num rows:4457541数据大小:1854337449基本统计信息:完整列统计信息:完整
在表中进行分区和扣合。
如何改进下面的查询。

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                                                                                                        |
|                                                                                                                                                                                                                             |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--+

这些参数都没有帮助我们在较短的时间内解决查询。

3hvapo4f

3hvapo4f1#

根据计划,查询在mapper上运行,未启用矢量化。试试这个:

set hive.vectorized.execution.enabled = true;
set hive.vectorized.execution.reduce.enabled=true;

调整Map器并行度:

set tez.grouping.max-size=67108864;
set tez.grouping.min-size=32000000;

使用这些设置可以增加正在运行的Map程序的数量。理想情况下,它应该在没有此设置的情况下运行:

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,您可以使用altertable concatenate命令连接文件。12个文件不是什么大问题,当查询单个分区时,您可能不会注意到改进。
另请参见以下答案:https://stackoverflow.com/a/48487306/2700344

相关问题