SHOW STATS_BUCKETS

The SHOW STATS_BUCKETS statement shows the bucket information in statistics.

Currently, the SHOW STATS_BUCKETS 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
Bucket_idThe ID of a bucket
CountThe number of all the values that falls on the bucket and the previous buckets
RepeatsThe occurrence number of the maximum value
Lower_boundThe minimum value
Upper_boundThe maximum value
NdvThe number of different values in the bucket. When tidb_analyze_version = 1, Ndv is always 0, which has no actual meaning.

Synopsis

ShowStatsBucketsStmt

SHOW STATS_BUCKETS - 图1

ShowLikeOrWhere

SHOW STATS_BUCKETS - 图2

  1. ShowStatsBucketsStmt ::=
  2. "SHOW" "STATS_BUCKETS" ShowLikeOrWhere?
  3. ShowLikeOrWhere ::=
  4. "LIKE" SimpleExpr
  5. | "WHERE" Expression

Examples

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

MySQL compatibility

This statement is a TiDB extension to MySQL syntax.

See also