Difference between partition and index in hive

后端 未结 2 724
轻奢々
轻奢々 2021-02-14 11:03

I am new in hadoop and hive and I would know what is the difference between index and partition in hive? When I use index and when partition?

Thank you!

2条回答
  •  梦如初夏
    2021-02-14 11:38

    Sonia,

    Below is a section from a book that may be useful to you.

    "Hive has limited indexing capabilities. There are no keys in the usual relational database sense, but you can build an index on columns to speed some operations. The index data for a table is stored in another table. Also, the feature is relatively new, so it doesn’t have a lot of options yet. However, the indexing process is designed to be customizable with plug-in Java code, so teams can extend the feature to meet their needs. Indexing is also a good alternative to partitioning when the logical partitions would actually be too numerous and small to be useful. Indexing can aid in pruning some blocks from a table as input for a MapReduce job. Not all queries can benefit from an index—the EXPLAIN syntax and Hive can be used to determine if a given query is aided by an index. Indexes in Hive, like those in relational databases, need to be evaluated carefully.

    Maintaining an index requires extra disk space and building an index has a processing cost. The user must weigh these costs against the benefits they offer when querying a table."

    Programming Hive Book Page 117

提交回复
热议问题