hive优化——严格模式

默认配置为: 


    hive.mapred.mode
    nonstrict
    The mode in which the Hive operations are being performed.
        In strict mode, some risky queries are not allowed to run. They include:
        Cartesian Product.
        No partition being picked up for a query.
        Comparing bigints and strings.
        Comparing bigints and doubles.
        Orderby without limit.
    

设置参数为:

set hive.mapred.mode = strict;

严格模式限制以下查询:

1、笛卡尔积查询:join查询不使用on语句而是使用where语句

关系型数据库的执行优化器可以高效地将where语句转化成on语句,hive并不会执行这种优化。

2、查询没有选择分区:对于分区表,where语句中无分区字段过滤条件

不允许用户扫描所有分区,因为分区表通常数据量巨大,没有限制分区的查询可能会消耗巨大资源。

3、order by没有limit语句:

order by 为了执行排序过程,会将所有的结果数据分发到同一个reducer中进行处理,增加limit语句可以防止reducer额外执行很长一段时间。

4、bigint类型数据与string和double类型比较

 

你可能感兴趣的:(hive优化——严格模式)