Description
Supported engines: Presto and SparkSQL
Purpose: Perform statistics on a database table.
Statement
ANALYZE TABLES [ { FROM | IN } database_name ] COMPUTE STATISTICS [ NOSCAN ]
ANALYZE TABLE table_identifier
[ PARTITION ( partition_col_name [ = partition_col_val ] [ , ... ] ) ]
COMPUTE STATISTICS [ NOSCAN | FOR COLUMNS col [ , ... ] | FOR ALL COLUMNS ]
Parameter
database_name
: Name of the database on which table statistics are performed.
table_identifier
: Name of the table on which statistics are performed.
partition_col_name
: Name of the column in the partitioned table on which statistics are performed.
partition_col_value
: Values in the column of the partitioned table on which statistics are performed.
Example
ANALYZE TABLE students COMPUTE STATISTICS
ANALYZE TABLE students COMPUTE STATISTICS FOR COLUMNS name
ANALYZE TABLE db.students COMPUTE STATISTICS FOR COLUMNS name
ANALYZE TABLE students COMPUTE STATISTICS NOSCAN
ANALYZE TABLE students COMPUTE STATISTICS FOR all COLUMNS
ANALYZE TABLE db.students COMPUTE STATISTICS FOR all COLUMNS
ANALYZE TABLE students PARTITION (student_id) COMPUTE STATISTICS
ANALYZE TABLE students PARTITION (student_id = 111111) COMPUTE STATISTICS
ANALYZE TABLE db.students PARTITION (student_id = 111111, name = 'test') COMPUTE STATISTICS FOR all COLUMNS
ANALYZE TABLES COMPUTE STATISTICS
ANALYZE TABLES COMPUTE STATISTICS NOSCAN
ANALYZE TABLES from school_db COMPUTE STATISTICS NOSCAN
ANALYZE TABLES IN school_db COMPUTE STATISTICS NOSCAN
Was this page helpful?