SHOW STATS_BUCKETS

SHOW STATS_BUCKETS 语句显示常规统计信息中桶的信息。

目前,SHOW STATS_BUCKETS 语句返回以下列:

列名说明
Db_name数据库名
Table_name表名
Partition_name分区名
Column_name取决于 Is_index 值:Is_index0 时显示列名,为 1 时显示索引名
Is_index是否是索引列
Bucket_id桶的 ID
Count该桶和之前桶中所有数值的个数
Repeats最大值的出现次数
Lower_bound最小值
Upper_bound最大值
Ndv桶中不同值的数量。该字段已废弃,其值由于不准确会始终显示为 0

语法图

ShowStatsBucketsStmt
SHOWSTATS_BUCKETSShowLikeOrWhere
ShowLikeOrWhere
LIKESimpleExprWHEREExpression

示例

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

MySQL 兼容性

该语句是 TiDB 对 MySQL 语法的扩展。

另请参阅

文档内容是否有帮助?