ANALYZE collects statistics about table contents in databases, and stores the results in the PG_STATISTIC system catalog. The execution plan generator uses these statistics to determine which one is the most effective execution plan.
1 2 | { ANALYZE | ANALYSE } [ { VERBOSE | LIGHT | FORCE | PREDICATE } ] [ table_name [ ( column_name [, ...] ) ] ]; |
1 2 3 | { ANALYZE | ANALYSE } [ { VERBOSE | LIGHT | FORCE } ] [ table_name [ ( column_name [, ...] ) ] ] PARTITION ( partition_name ) ; |
1 2 | { ANALYZE | ANALYSE } [ VERBOSE ] { foreign_table_name | FOREIGN TABLES }; |
1 2 | {ANALYZE | ANALYSE} [ VERBOSE ] table_name (( column_1_name, column_2_name [, ...] )); |
1 | {ANALYZE | ANALYSE} VERIFY {FAST|COMPLETE}; |
1 | {ANALYZE | ANALYSE} VERIFY {FAST|COMPLETE} table_name|index_name [CASCADE]; |
1 | {ANALYZE | ANALYSE} VERIFY {FAST|COMPLETE} table_name PARTITION {(partition_name)}[CASCADE]; |
Enables the display of progress messages.
If this parameter is specified, progress information is displayed by ANALYZE to indicate the table that is being processed, and statistics about the table are printed.
In lightweight mode, the statistics collected for a table are saved to the memory instead of being written to the system catalog. A level-1 lock is added to the table during Analyze.
In FORCE mode, table statistics can be forcibly refreshed when they are locked.
In PREDICATE mode, statistics are calculated only for the currently identified predicate columns. Predicate information is collected during query parsing, and dynamic sampling supports predicate column sampling. For details, see the GUC parameter analyze_predicate_column_threshold. This is supported only by clusters of version 9.1.0.100 or later.
Specifies the name (possibly schema-qualified) of a specific table to analyze. If omitted, all regular tables (but not foreign tables) in the current database are analyzed.
Currently, you can use ANALYZE to collect statistics about row-store tables, column-store tables, HDFS tables, ORC- or CARBONDATA-formatted OBS foreign tables, and foreign tables for collaborative analysis.
Value range: an existing table name
Specifies the name of a specific column to analyze. All columns are analyzed by default.
Value range: an existing column name
Assumes the table is a partitioned table. You can specify partition_name following the keyword PARTITION to analyze the statistics of this table. Currently the partitioned table supports the syntax of analyzing a partitioned table, but does not execute this syntax.
Value range: a partition name in a table
Specifies the name (possibly schema-qualified) of a specific table to analyze. The data of the table is stored in HDFS.
Value range: an existing table name
Analyzes HDFS foreign tables stored in HDFS and accessible to the current user.
Name of the index table to be analyzed. The name may contain the schema name.
Value range: an existing table name
For row-store tables, the CRC and page header of row-store tables are verified in FAST mode. If the verification fails, an alarm is reported. In COMPLETE mode, parse and verify the pointers and tuples of row-store tables. For column-store tables, the CRC and magic of column-store tables are verified in FAST mode. If the verification fails, an alarm is reported. In COMPLETE mode, parse and verify CU of column-store tables.
In CASCADE mode, all indexes of the current table are checked.
1 | ANALYZE customer_info; |
1 2 3 4 5 | ANALYZE VERBOSE customer_info; INFO: analyzing "cstore.pg_delta_3394584009"(cn_5002 pid=53078) INFO: analyzing "public.customer_info"(cn_5002 pid=53078) INFO: analyzing "public.customer_info" inheritance tree(cn_5002 pid=53078) ANALYZE |