Generating and viewing Apache Hive statistics in Cloudera Data Warehouse

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.

  1. Launch a Hive shell or editor.
  2. Gather table statistics for the non-partitioned table mytable:
    ANALYZE TABLE mytable COMPUTE STATISTICS;
  3. View table statistics you generated:
    DESCRIBE EXTENDED mytable;
  4. Gather column-level statistics for the table:
    ANALYZE TABLE mytable COMPUTE STATISTICS FOR COLUMNS;
  5. View column statistics for the col_name column in my_table in the my_db database:
    DESCRIBE FORMATTED my_db.my_table col_name;