0% found this document useful (0 votes)
16 views2 pages

Enabling Vectorization in Hive Queries

Vectorization allows Hive to process batches of rows together rather than one at a time to improve performance. It can be enabled by setting hive.vectorized.execution.enabled to true. Hive will log whether a query was vectorized. Vectorization currently supports single table read-only queries with selection, filtering, and grouping operators on many data types for ORC files.

Uploaded by

Pranoy
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

Enabling Vectorization in Hive Queries

Vectorization allows Hive to process batches of rows together rather than one at a time to improve performance. It can be enabled by setting hive.vectorized.execution.enabled to true. Hive will log whether a query was vectorized. Vectorization currently supports single table read-only queries with selection, filtering, and grouping operators on many data types for ORC files.

Uploaded by

Pranoy
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Query 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:
[Link]=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

Only the ORC file format is supported in the current implementation.

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

Common questions

Powered by AI

The current implementation of Hive's vectorization is limited to single table read-only queries. It does not support DDL queries or DML queries, which restricts its applicability in scenarios requiring data manipulation or schema modification. The operators supported are limited to selection, filter, and group by; even though partitioned tables are supported, only certain data types such as tinyint, smallint, int, etc., and certain expressions like comparison, arithmetic, and logical operations, are allowed. Additionally, only the ORC file format is supported for vectorization .

Column vector processing in Hive offers several advantages over traditional row-by-row processing. By working with entire column vectors at once, vectorization dramatically enhances instruction pipeline efficiency and cache utilization. This approach minimizes the computational overhead associated with processing each row individually, as seen in row-by-row methods, which include multiple method calls, deserialization complexities, and object inspection layers. Consequently, vectorization provides significant CPU usage reductions, improving the instructions per cycle metric and overall query execution speed .

Hive will disable vectorization when it determines that the query or the data cannot support vectorized execution. This includes scenarios where the query involves unsupported functionalities such as DDL or DML operations, or unsupported data types or expressions. If vectorization cannot be applied, Hive will execute the query with vectorization turned off, thus reverting to a non-vectorized mode of processing the query .

To enable vectorized execution in Hive, the configuration parameter 'hive.vectorized.execution.enabled' needs to be set to true. Once vectorization is enabled, Hive examines the query and data to determine if vectorization is applicable. During execution, the Hive client logs info-level messages to indicate whether a query's execution is being vectorized. More detailed logs are available at the debug level, and the logs can also be displayed on the console .

The ORC file format is supported in Hive's vectorized execution because ORC is optimized for efficient, bulk columnar storage and query processing. It aligns well with vectorized processing's need for rapid access to column data and bulk processing capabilities. This specialized optimization likely improves performance and simplifies implementation by not having to accommodate multiple file formats with varying support structures. The exclusive support of ORC might limit scenarios where other formats are prevalent or preferred, requiring data conversion, but it provides focused enhancements in scenarios leveraging ORC's efficient data handling .

Hive's vectorization feature supports data types such as tinyint, smallint, int, bigint, date, boolean, float, double, timestamp, string, char, varchar, and binary. The supported expressions include comparison (e.g., >, >=, <, <=, =, !=), arithmetic (e.g., plus, minus, multiply, divide, modulo), logical (AND, OR), and aggregate functions (e.g., sum, avg, count, min, max). These limitations likely exist because vectorization requires data and operations that can efficiently utilize columnar processing and minimal computational overhead when vectorized, ensuring that performance gains are realized without added complexity or unsupported dependencies .

Hive's vectorization approach provides 'excellent instructions per cycle' by optimizing the processing pipeline to reduce latency and improve throughput. This is achieved by processing large batches of rows simultaneously, minimizing overhead from method calls, deserialization, and unnecessary branching (e.g., if-then-else statements). This efficiency leads to better utilization of CPU cycles and processor pipelines, resulting in faster query performance through increased instructions executed per unit of time. These enhancements contribute to reduced CPU time and enhanced overall system performance .

Hive's vectorized processing supports functional operations such as selection, filtering, grouping, comparison, arithmetic, logical operations, and aggregates like sum, avg, count, min, and max. By supporting these operations, vectorized processing allows efficient query execution as it can perform complex data manipulations across large datasets in one simultaneous process rather than sequentially. These operations align well with batch processing, reducing overhead and improving execution dynamics, such as faster processing speeds and reduced latency .

The use of vectorized execution for partitioned tables in Hive can significantly enhance query performance. Partitioning allows Hive to efficiently read only the necessary segments of data relevant to the query, reducing I/O operations and improving query efficiency. When combined with vectorization, which processes large batches of rows across the partitioned segments, the query performance sees marked improvement due to reduced processing overhead and enhanced data handling efficiency. This combination leverages efficient data access patterns and reduces CPU load, resulting in faster query response times .

Vectorization in Hive improves CPU usage by allowing Hive to process a batch of rows together instead of processing one row at a time. This mode of processing is more efficient as it eliminates unnecessary method calls and deserialization, improves cache usage, and enhances processor pipeline utilization. By operating on whole column vectors rather than individual rows, vectorization minimizes the overhead that typically accompanies row-by-row processing. Additionally, it reduces the reliance on complex virtual method calls that slow down processing, ultimately improving the instructions per cycle and reducing overall CPU time used .

You might also like