---
title: "explain hive index"
author: "乡里伢崽"
date: "2014-08-24T16:44:01Z"
tags: []
categories: ["编程语言"]
slug: "explain-hive-index"
draft: false
lastmod: "2014-08-27T12:34:11Z"
id: 2108298
url: "https://crazymatrix.iteye.com/blog/2108298"
---

设置索引：
使用聚合索引优化groupby操作
hive> set hive.optimize.index.groupby=false;

自动使用索引
hive> set hive.optimize.index.filter=true;                      

设置自动使用索引的最小输入字节数
hive>set hive.optimize.index.filter.compact.minsize=64

注意 hive.optimize.index.groupby必须设置生false，不然 hive.optimize.index.filter不起作用。



hive> explain select count(1) from ctest where dp_id='10275499';
 view plaincopy
STAGE PLANS:  
  Stage: Stage-3  
    Map Reduce  
      Alias -> Map Operator Tree:  
        taobao_db__aatest_aatestindex__   
          TableScan  
            alias: taobao_db__aatest_aatestindex__  
            filterExpr:  
                expr: (tid = '57301233')  
                type: boolean  
            Filter Operator  
可以发现会执行索引。