SHOW STATS_TOPN

The SHOW STATS_TOPN statement shows the Top-N information in statistics.

Currently, the SHOW STATS_TOPN statement returns the following columns:

Column nameDescription
Db_nameThe database name
Table_nameThe table name
Partition_nameThe partition name
Column_nameThe column name (when is_index is 0) or the index name (when is_index is 1)
Is_indexWhether it is an index column or not
ValueThe value of this column
CountHow many times the value appears

Synopsis

ShowStatsTopnStmt
SHOWSTATS_TOPNShowLikeOrWhere
ShowLikeOrWhere
LIKESimpleExprWHEREExpression

Example

SHOW STATS_TOPN WHERE Table_name='t';
+---------+------------+----------------+-------------+----------+--------------------------+-------+ | Db_name | Table_name | Partition_name | Column_name | Is_index | Value | Count | +---------+------------+----------------+-------------+----------+--------------------------+-------+ | test | t | | a | 0 | 2023-12-27 00:00:00 | 1 | | test | t | | a | 0 | 2023-12-28 00:00:00 | 1 | | test | t | | ia | 1 | (NULL, 2) | 1 | | test | t | | ia | 1 | (NULL, 4) | 1 | | test | t | | ia | 1 | (2023-12-27 00:00:00, 1) | 1 | | test | t | | ia | 1 | (2023-12-28 00:00:00, 3) | 1 | +---------+------------+----------------+-------------+----------+--------------------------+-------+ 6 rows in set (0.00 sec)

MySQL compatibility

This statement is a TiDB extension to MySQL syntax.

See also

Was this page helpful?