Overview of Hive Indexes
The goal of Hive indexing is to improve the speed of query lookup on certain columns of a table. Without an index, queries with predicates like 'WHERE tab1.col1 = 10' load the entire table or partition and process all the rows. But if an index exists for col1, then only a portion of the file needs to be loaded and processed.
The improvement in query speed that an index can provide comes at the cost of additional processing to create the index and disk space to store the index.
Documentation and examples of how to use Hive indexes can be found here:
- Indexed Hive – overview and examples by Prafulla Tekawade and Nikhil Deshpande, October 2010
- Tutorial: SQL-like join and index with MapReduce using Hadoop and Hive – blog by Ashish Garg, April 2012
Configuration Parameters for Hive Indexes
The Configuration Properties document describes parameters that configure Hive indexes.
This section gives some indexing examples adapted from the Hive test suite.
Create/build, show, and drop index:
Create then build, show formatted (with column names), and drop index:
Create bitmap index, build, show, and drop:
Create index in a new table:
Create index stored as RCFile:
Create index stored as text file:
Create index with index properties:
Create index with table properties:
Drop index if exists:
Rebuild index on a partition: