Performance Optimization in Hive
Performance Optimization in Hive :
Enable Compression in Hive.
Optimize Joins. Auto Map Joins. Skew Joins. Enable Bucketed Map Joins.
Avoid Global Sorting in Hive.
Enable Tez Execution Engine.
Optimize LIMIT operator.
Enable Parallel Execution.
Enable Mapreduce Strict Mode.
Single Reduce for Multi Group BY.
Enable CBO
Enable Vectorization
Use ORC file format
Control Parallel Reduce Task
Configuration for enabling and using CBO :
hive.stats.autogather
hive.cbo.enable
hive.stats.fetch. column.stats
hive.compute.query. using.stats
The following example generates statistics for all columns in the customer table:
ANALYZE TABLE customer PARTITION (dt) COMPUTE STATISTICS FOR COLUMNS;
Viewing generated statistics
DESCRIBE EXTENDED customer;
The following example displays statistics for the region column in the customer table:
DESCRIBE FORMATTED cutomer.region;
Compression Settings and enabling them :
set hive.exec.compress.output=true;
set mapreduce.output.fileoutputformat.compress=true;
set mapreduce.output.fileoutputformat.compress.codec=org.apache.hadoop.io.compress.GzipCodec;
SET mapreduce.output.fileoutputformat.compress.codec=com.hadoop.compression.lzo.LzoCodec
set mapreduce.output.fileoutputformat.compress.type=BLOCK;
set hive.exec.compress.intermediate=true;
Enable Tez Execution Engine :
set hive.execution.engine=tez;
Avoid Global Sorting :
Considering employee table
SELECT id, name, salary, dept FROM employee
DISTRIBUTE BY dept
SORT BY id ASC, name DESC;
Single Reduce for Multi Group BY :
hive.multigroupby.singlereducer=true ;
Enable Vectorization :
hive.vectorized.execution.enabled = true;
explain select count(*) from vectorizedtable;
Enable Parallel execution :
set hive.exec.parallel=true;
set hive.exec.parallel.thread.number=8;
Enable Mapreduce Strict Mode :
set hive.mapred.mode=strict;
hive.exec.dynamic.partition.mode=strict
Single Reduce for Multi Group BY :
hive.multigroupby.singlereducer=true
Optimize Joins. Auto Map Joins. Skew Joins. Enable Bucketed Map Joins :
hive.optimize.bucketmapjoin=true
hive.optimize.bucketmapjoin.sortedmerge=true
Optimize LIMIT operator :
hive.limit.optimize.enable=true
hive.limit.row.max.size=100000
hive.limit.optimize.limit.file=10
hive.limit.optimize.fetch.max=50000
Control Parallel Reduce Task :
SET mapreduce.job.reduces=10
Use ORC file Format :
CREATE TABLE addresses (
name string,
street string,
city string,
state string,
zip int
) STORED AS orc tblproperties ("orc.compress"="Zlib");
Performance Optimization in Hive :
Enable Compression in Hive.
Optimize Joins. Auto Map Joins. Skew Joins. Enable Bucketed Map Joins.
Avoid Global Sorting in Hive.
Enable Tez Execution Engine.
Optimize LIMIT operator.
Enable Parallel Execution.
Enable Mapreduce Strict Mode.
Single Reduce for Multi Group BY.
Enable CBO
Enable Vectorization
Use ORC file format
Control Parallel Reduce Task
Configuration for enabling and using CBO :
hive.stats.autogather
hive.cbo.enable
hive.stats.fetch. column.stats
hive.compute.query. using.stats
The following example generates statistics for all columns in the customer table:
ANALYZE TABLE customer PARTITION (dt) COMPUTE STATISTICS FOR COLUMNS;
Viewing generated statistics
DESCRIBE EXTENDED customer;
The following example displays statistics for the region column in the customer table:
DESCRIBE FORMATTED cutomer.region;
Compression Settings and enabling them :
set hive.exec.compress.output=true;
set mapreduce.output.fileoutputformat.compress=true;
set mapreduce.output.fileoutputformat.compress.codec=org.apache.hadoop.io.compress.GzipCodec;
SET mapreduce.output.fileoutputformat.compress.codec=com.hadoop.compression.lzo.LzoCodec
set mapreduce.output.fileoutputformat.compress.type=BLOCK;
set hive.exec.compress.intermediate=true;
Enable Tez Execution Engine :
set hive.execution.engine=tez;
Avoid Global Sorting :
Considering employee table
SELECT id, name, salary, dept FROM employee
DISTRIBUTE BY dept
SORT BY id ASC, name DESC;
Single Reduce for Multi Group BY :
hive.multigroupby.singlereducer=true ;
Enable Vectorization :
hive.vectorized.execution.enabled = true;
explain select count(*) from vectorizedtable;
Enable Parallel execution :
set hive.exec.parallel=true;
set hive.exec.parallel.thread.number=8;
Enable Mapreduce Strict Mode :
set hive.mapred.mode=strict;
hive.exec.dynamic.partition.mode=strict
Single Reduce for Multi Group BY :
hive.multigroupby.singlereducer=true
Optimize Joins. Auto Map Joins. Skew Joins. Enable Bucketed Map Joins :
hive.optimize.bucketmapjoin=true
hive.optimize.bucketmapjoin.sortedmerge=true
Optimize LIMIT operator :
hive.limit.optimize.enable=true
hive.limit.row.max.size=100000
hive.limit.optimize.limit.file=10
hive.limit.optimize.fetch.max=50000
Control Parallel Reduce Task :
SET mapreduce.job.reduces=10
Use ORC file Format :
CREATE TABLE addresses (
name string,
street string,
city string,
state string,
zip int
) STORED AS orc tblproperties ("orc.compress"="Zlib");
4 comments:
best
This article provides a useful overview of Apache Hive performance optimization techniques, including compression, join optimization, Tez execution, vectorization, ORC file formats, and Cost-Based Optimization (CBO). Understanding how to gather table and column statistics using the ANALYZE TABLE command is particularly valuable for improving query planning and processing efficiency in large-scale data environments.
Students interested in practical big data implementation can explore Big Data Projects to discover project ideas involving distributed data processing, Hadoop ecosystems, and large-scale analytics.
For professionals looking to strengthen their skills in data pipelines, distributed processing, and big data technologies, Data Engineering Online Training in India is a relevant resource for developing practical data engineering knowledge.
Applying Hive optimization techniques to analytical workloads also provides a strong foundation for understanding data-driven applications. Students can explore Data Science Projects for Final Year for project ideas that connect data processing with analytical problem-solving.
Post a Comment