Enable Vectorization in Hive
Enable Vectorization in Hive
Vectorization allows Hive to process a batch of rows together instead of processing one row at a time.
Each batch is usually an array of primitive types. Operations are performed on the entire column
vector, which improves the instruction pipelines and cache usage.
Enable Vectorization in Hive
To enable vectorization, set this configuration parameter:
hive.vectorized.execution.enabled=true
When vectorization is enabled, Hive examines the query and the data to determine whether
vectorization can be supported. If it cannot be supported, Hive will execute the query with
vectorization turned off.
Log Information about Vectorized Execution of Queries
The Hive client will log, at the info level, whether a query's execution is being vectorized. More
detailed logs are printed at the debuglevel.
The client logs can also be configured to show up on the console.
Supported Functionality
The current implementation supports only single table read-only queries. DDL queries or DML queries
are not supported.
The supported operators are selection, filter and group by.
Partitioned tables are supported.
These data types are supported:
tinyint
smallint
int
bigint
date
boolean
float
double
timestamp
string
char
varchar
binary
These expressions are supported:
Comparison: >, >=, <, <=, =, !=
Arithmetic: plus, minus, multiply, divide, modulo
Logical: AND, OR
Vectorization pg. 1
Aggregates: sum, avg, count, min, max
The Hive query execution engine currently processes one row at a time. A single row of data goes through all
the operators before the next row can be processed. This mode of processing is very inefficient in terms of
CPU usage. Research has demonstrated that this yields very low instructions per cycle. Also currently Hive
heavily relies on lazy deserialization and data columns go through a layer of object inspectors that identify
column type, deserialize data and determine appropriate expression routines in the inner loop. These layers of
virtual method call further slowdown the processing.
This work will add support for vectored query execution to Hive, where, instead of individual rows, batches of
about a thousand rows at a time are processed. Each column in the batch is represented as a vector of a
primitive data type. The inner loop of execution scans these vectors very fast, avoiding method calls,
deserialization, unnecessary if-then-else, etc. This substantially reduces CPU time used, and gives excellent
instructions per cycle (i.e. improved processor pipeline utilization).
Vectorization pg. 2