SHOW STATS_HISTOGRAMS

你可以使用 SHOW STATS_HISTOGRAMS 语句查看统计信息中直方图的相关信息。

语法图

ShowStmt

ShowStmt

ShowTargetFiltertable

ShowTargetFilterable

ShowLikeOrWhereOpt

ShowLikeOrWhereOpt

示例

  1. show stats_histograms;
  1. +---------+------------+----------------+-------------+----------+---------------------+----------------+------------+--------------+-------------+
  2. | Db_name | Table_name | Partition_name | Column_name | Is_index | Update_time | Distinct_count | Null_count | Avg_col_size | Correlation |
  3. +---------+------------+----------------+-------------+----------+---------------------+----------------+------------+--------------+-------------+
  4. | test | t | | a | 0 | 2020-05-25 19:20:00 | 7 | 0 | 1 | 1 |
  5. | test | t2 | | a | 0 | 2020-05-25 19:20:01 | 6 | 0 | 8 | 0 |
  6. | test | t2 | | b | 0 | 2020-05-25 19:20:01 | 6 | 0 | 1.67 | 1 |
  7. +---------+------------+----------------+-------------+----------+---------------------+----------------+------------+--------------+-------------+
  8. 3 rows in set (0.00 sec)
  1. show stats_histograms where table_name = 't2';
  1. +---------+------------+----------------+-------------+----------+---------------------+----------------+------------+--------------+-------------+
  2. | Db_name | Table_name | Partition_name | Column_name | Is_index | Update_time | Distinct_count | Null_count | Avg_col_size | Correlation |
  3. +---------+------------+----------------+-------------+----------+---------------------+----------------+------------+--------------+-------------+
  4. | test | t2 | | b | 0 | 2020-05-25 19:20:01 | 6 | 0 | 1.67 | 1 |
  5. | test | t2 | | a | 0 | 2020-05-25 19:20:01 | 6 | 0 | 8 | 0 |
  6. +---------+------------+----------------+-------------+----------+---------------------+----------------+------------+--------------+-------------+
  7. 2 rows in set (0.00 sec)

MySQL 兼容性

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

另请参阅