更新时间:2026-07-03 GMT+08:00
ANALYZE | ANALYSE
功能描述
用于收集有关数据库中表内容的统计信息,统计结果存储在LakeFormation上。执行计划生成器会使用这些统计数据,以确定最有效的执行计划。
能够执行ANALYZE特定表的用户,包括表的所有者、被授予该表上读取权限的用户。
注意事项
ANALYZE会扫描表数据,同时会产生计费。
语法格式
收集全表的统计信息。
1 | { ANALYZE | ANALYSE } table_name; |
收集分区表某一分区的统计信息
1 | { ANALYZE | ANALYSE } table_name (predicate_condition); |
参数说明
table_name
需要分析的特定表的表名(可能会带模式名)。
取值范围:已有的表名。
predicate_condition
分区谓词条件。
取值范围:正确的分区定义及分区值
示例
使用ANALYZE语句更新表customer_info统计信息:
1 | ANALYZE customer_info; |
使用ANALYZE语句更新表partition_customer_info中某一分区统计信息:
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; -- 假设此时已有分区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; -- 假设此时已有分区b=1, e='abcd' ANALYZE partition_customer_info (b=1,e='abcd'); -- 假设此时已有分区b=2, e 为 null ANALYZE partition_customer_info (b=1,e = NULL); |
父主题: DCL语法