tencent cloud

文档反馈

ANALYZE TABLES

最后更新时间:2024-08-07 17:20:01

    说明

    支持内核:Presto、SparkSQL。
    用途:支持对数据库表进行统计。

    语法

    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 ]

    参数

    database_name:需要计算统计信息的表所在的数据库。
    table_identifier:需要计算统计信息的表名。
    partition_col_name:需要计算统计信息的分区列名。
    partition_col_value:需要计算统计信息的分区列的值。

    示例

    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
    联系我们

    联系我们,为您的业务提供专属服务。

    技术支持

    如果你想寻求进一步的帮助,通过工单与我们进行联络。我们提供7x24的工单服务。

    7x24 电话支持