tencent cloud

Feedback

ANALYZE TABLES

Last updated: 2024-08-07 17:19:54

    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
    
    
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support