Generate and view Apache Hive statistics
You can use statistics to optimize queries for improved performance. The cost-based optimizer (CBO) also uses statistics to compare query plans and choose the best one. By viewing statistics instead of running a query, you can often get answers to your data questions faster.
This task shows how to generate different types of statistics about a table.
- Launch a Hive shell and log in.
Gather table statistics for the non-partitioned table
ANALYZE TABLE mytable COMPUTE STATISTICS;
View table statistics you generated:
DESCRIBE EXTENDED mytable;
Gather column-level statistics for the table:
ANALYZE TABLE mytable COMPUTE STATISTICS FOR COLUMNS;
View column statistics for the
DESCRIBE FORMATTED my_db.my_table col_name;