Updated on 2025-10-23 GMT+08:00

statistics

The statistics view provides information about complete columns of table indexes. This view is read-only. All users have the read permission on this view. Some information in the view is obtained based on statistics. Run ANALYZE before checking the information. (If data is updated in the database, you are advised to delay running ANALYZE.) If an index column is not a complete column in the table, the index column is not recorded in this view.

Table 1 information_schema.statistics columns

Name

Type

Description

TABLE_CATALOG

varchar(512)

Name of the database. When lower_case_table_names is set to 0, the value of this column is case-sensitive. When lower_case_table_names is set to 1, the value of this column is case-insensitive.

TABLE_SCHEMA

varchar(64)

Name of the schema to which the table containing the index belongs. When lower_case_table_names is set to 0, the value of this column is case-sensitive. When lower_case_table_names is set to 1, the value of this column is case-insensitive.

TABLE_NAME

varchar(64)

Name of the table containing the index. When lower_case_table_names is set to 0, the value of this column is case-sensitive. When lower_case_table_names is set to 1, the value of this column is case-insensitive.

NON_UNIQUE

bigint

Specifies whether the index is a non-unique index. 0 if the index is unique; 1 if it is not.

INDEX_SCHEMA

varchar(64)

Name of the schema to which the index belongs. When lower_case_table_names is set to 0, the value of this column is case-sensitive. When lower_case_table_names is set to 1, the value of this column is case-insensitive.

INDEX_NAME

varchar(64)

Name of the index. If the index is the primary key, the name is always primary. Otherwise, the name is the actual index name.

SEQ_IN_INDEX

bigint

Column sequence number in the index.

COLUMN_NAME

varchar(64)

Name of the index column.

COLLATION

varchar(1)

Collation mode of columns in the index. The value is A (ascending) or D (descending).

CARDINALITY

bigint

Estimate of the number of unique values in the index.

SUB_PART

bigint

Index prefix. If the column is only partially indexed, the value is the number of index characters. If the entire column is indexed, the value is NULL.

PACKED

varchar(10)

This column is not supported in the current version, and it is null.

NULLABLE

varchar(3)

Specifies whether the index column can contain null values. yes: The column can contain null values. ": It cannot contain null values.

INDEX_TYPE

varchar(16)

Index method used, such as BTREE and UBTREE.

COMMENT

varchar(16)

This column is not supported in the current version, and it is null.

INDEX_COMMENT

varchar(1024)

Comment of the index.

Run ANALYZE to update the statistics and then check the view.

my_db=# create table t1(a int);
CREATE TABLE
my_db=# insert into t1 values (1),(2);
INSERT 0 2
my_db=# create index t1_index_1 on t1(a);
CREATE INDEX
my_db=# analyze;
ANALYZE
my_db=# select table_catalog,table_name,index_name,index_type, cardinality from information_schema.statistics where table_name='t1';
 table_catalog | table_name | index_name | index_type | cardinality
---------------+------------+------------+------------+-------------
 my_db         | t1         | t1_index_1 | UBTREE     |           2
(1 row)