Skip to main content

SHOW COLUMN STATS

Description​

This statement is used to show the column statistics of a table.

Syntax​

SHOW COLUMN [CACHED] STATS <table_name> [ (<column_name> [, ...]) ];

Required Parameters​

1. <table_name>

The name of the table for which column statistics needs to be displayed.

Optional Parameters​

1. CACHED

Show the column statistics in FE cache. When not specified, the information persisted in the statistics table is displayed by default.

2. <column_name>

Specify the column names that need to be displayed. The column names must exist in the table, and multiple column names are separated by commas. If not specified, the information of all columns will be displayed by default.

Return Value​

ColumnNote
column_namecolumn name
index_nameindex name
countcolumn row count
ndvcolumn distinct value
num_nullcolumn null count
data_sizecolumn total data size
avg_size_bytecolumn average size
minmin value
maxmax value
methodcollect method
typecollect type
triggerjob trigger method
query_timesquery times
updated_timeupdate time
update_rowsupdate rows when last analyze
last_analyze_row_counttable row count when last analyze
last_analyze_versiontable version when last analyze

Access Control Requirements​

The user who executes this SQL must have at least the following permissions:

PrivilegeObjectNotes
SELECT_PRIVTableWhen executing SHOW, the SELECT_PRIV privilege for the queried table is required.

Examples​

  1. Show the statistics of all columns in table test1.
SHOW COLUMN STATS test1;
+-------------+------------+----------+---------+----------+-----------+---------------+--------+--------+--------+--------------+---------+-------------+---------------------+-------------+------------------------+----------------------+
| column_name | index_name | count | ndv | num_null | data_size | avg_size_byte | min | max | method | type | trigger | query_times | updated_time | update_rows | last_analyze_row_count | last_analyze_version |
+-------------+------------+----------+---------+----------+-----------+---------------+--------+--------+--------+--------------+---------+-------------+---------------------+-------------+------------------------+----------------------+
| name | test1 | 87775.0 | 48824.0 | 0.0 | 351100.0 | 4.0 | '0001' | 'ffff' | FULL | FUNDAMENTALS | MANUAL | 0 | 2025-02-05 12:17:08 | 0 | 100000 | 3 |
| id | test1 | 100000.0 | 8965.0 | 0.0 | 351400.0 | 3.514 | 1000 | 9999 | SAMPLE | FUNDAMENTALS | MANUAL | 0 | 2025-02-05 12:17:41 | 0 | 100000 | 3 |
+-------------+------------+----------+---------+----------+-----------+---------------+--------+--------+--------+--------------+---------+-------------+---------------------+-------------+------------------------+----------------------+
  1. Show the statistics of all columns in the test1 in the current FE cache.
SHOW COLUMN CACHED STATS test1;
+-------------+------------+----------+---------+----------+-----------+---------------+--------+--------+--------+--------------+---------+-------------+---------------------+-------------+------------------------+----------------------+
| column_name | index_name | count | ndv | num_null | data_size | avg_size_byte | min | max | method | type | trigger | query_times | updated_time | update_rows | last_analyze_row_count | last_analyze_version |
+-------------+------------+----------+---------+----------+-----------+---------------+--------+--------+--------+--------------+---------+-------------+---------------------+-------------+------------------------+----------------------+
| name | test1 | 87775.0 | 48824.0 | 0.0 | 351100.0 | 4.0 | '0001' | 'ffff' | FULL | FUNDAMENTALS | MANUAL | 0 | 2025-02-05 12:17:08 | 0 | 100000 | 3 |
| id | test1 | 100000.0 | 8965.0 | 0.0 | 351400.0 | 3.514 | 1000 | 9999 | SAMPLE | FUNDAMENTALS | MANUAL | 0 | 2025-02-05 12:17:41 | 0 | 100000 | 3 |
+-------------+------------+----------+---------+----------+-----------+---------------+--------+--------+--------+--------------+---------+-------------+---------------------+-------------+------------------------+----------------------+