SHOW STATS_HISTOGRAMS
你可以使用 SHOW STATS_HISTOGRAMS
语句查看通过 ANALYZE
语句 收集的直方图信息,该内容是数据库 统计信息 的一部分。
语法图
- ShowStatsHistogramsStmt
- ShowLikeOrWhere
ShowStatsHistogramsStmt ::=
"SHOW" "STATS_HISTOGRAMS" ShowLikeOrWhere?
ShowLikeOrWhere ::=
"LIKE" SimpleExpr
| "WHERE" Expression
示例
SHOW STATS_HISTOGRAMS;
+---------+------------+----------------+-------------+----------+---------------------+----------------+------------+--------------+-------------+
| Db_name | Table_name | Partition_name | Column_name | Is_index | Update_time | Distinct_count | Null_count | Avg_col_size | Correlation |
+---------+------------+----------------+-------------+----------+---------------------+----------------+------------+--------------+-------------+
| test | t | | a | 0 | 2020-05-25 19:20:00 | 7 | 0 | 1 | 1 |
| test | t2 | | a | 0 | 2020-05-25 19:20:01 | 6 | 0 | 8 | 0 |
| test | t2 | | b | 0 | 2020-05-25 19:20:01 | 6 | 0 | 1.67 | 1 |
+---------+------------+----------------+-------------+----------+---------------------+----------------+------------+--------------+-------------+
3 rows in set (0.00 sec)
SHOW STATS_HISTOGRAMS WHERE table_name = 't2';
+---------+------------+----------------+-------------+----------+---------------------+----------------+------------+--------------+-------------+
| Db_name | Table_name | Partition_name | Column_name | Is_index | Update_time | Distinct_count | Null_count | Avg_col_size | Correlation |
+---------+------------+----------------+-------------+----------+---------------------+----------------+------------+--------------+-------------+
| test | t2 | | b | 0 | 2020-05-25 19:20:01 | 6 | 0 | 1.67 | 1 |
| test | t2 | | a | 0 | 2020-05-25 19:20:01 | 6 | 0 | 8 | 0 |
+---------+------------+----------------+-------------+----------+---------------------+----------------+------------+--------------+-------------+
2 rows in set (0.00 sec)
MySQL 兼容性
该语句是 TiDB 对 MySQL 语法的扩展。