Updated on 2026-11-06 GMT+08:00

ANALYZE | ANALYSE

Function

Collects statistics about table contents in databases. The statistical results are stored in LakeFormation. The execution plan generator uses this statistical data to determine the most efficient execution plan.

Users capable of executing ANALYZE on a specific table include the table's owner and users granted read permissions on the table.

Precautions

ANALYZE scans data in the table and generates billing records.

Syntax

Collect statistics for the entire table.
1
{ ANALYZE | ANALYSE } table_name;

Collect statistics about a specific partition in a partitioned table.

1
{ ANALYZE | ANALYSE } table_name (predicate_condition);

Parameter Description

  • table_name

    Name of the specific table to be analyzed (may include schema qualification).

    Range: an existing table name.

  • predicate_condition

    Partitioning predicate condition.

    Range: correct partition definitions and corresponding partition values.

Examples

Update statistics for the customer_info table using ANALYZE:
1
ANALYZE customer_info;
Update statistics for a specific partition in the partition_customer_info table:
1
2
3
4
5
6
7
8
9
CREATE TABLE partition_customer_info (a char(3),c date, d text) partition by (b bigint, month(c), bucket(3,d)) store as iceberg;
-- Assume partitions exist: b=1, c_month=2024-05, d_bucket=5
ANALYZE partition_customer_info (b=1,month(c)='2024-05',bucket(3,d)=5);

CREATE TABLE partition_customer_info (a char(3),c date) partition by (b bigint, e text) store as parquet;
-- Assume partitions exist: b=1, e='abcd'
ANALYZE partition_customer_info (b=1,e='abcd');
-- Assume partitions exist: b=2, e=null
ANALYZE partition_customer_info (b=1,e is NULL);