Impala Compute Stats

Cloudera Impala provides an interface for executing SQL queries on data(Big Data) stored in HDFS or HBase in a fast and interactive way. Impala improves the performance of an SQL query by applying various optimization techniques. “Compute Stats” is one of these optimization techniques.

“Compute Stats” collects the details of the volume and distribution of data in a table and all associated columns and partitions. The information is stored in the metastore database and used by Impala to help optimize queries. This would help in preparing the efficient query plan before executing a query on a large table.


The PARTITION clause is only allowed in combination with the INCREMENTAL clause. It is optional for COMPUTE INCREMENTAL STATS, and required for DROP INCREMENTAL STATS. Whenever you specify partitions through the PARTITION (partition_spec) clause in a COMPUTE INCREMENTAL STATS or DROP INCREMENTAL STATSstatement, you must include all the partitioning columns in the specification, and specify constant values for all the partition key columns.

COMPUTE STATS will prepare the stats of entire table whereas COMPUTE INCREMENTAL STATS will work only on few of the partitions rather than the whole table. It will be helpful if the table is very large and takes a lot of time in performing COMPUTE STATS for the entire table each time a partition added or dropped.

We can see the stats of a table using the SHOW TABLE STATS command.

#Rows column displays -1 for all the partitions as the stats have not been created yet.


Let’s see the usage of Compute Stats:

Once we perform compute [incremental] stats on a table, the #Rows details get updated with the actual table records in those respective partitions.

Impala uses these details in preparing best query plan for executing a user query.




Leave a Reply

Your email address will not be published.