Skip to content

Latest commit

 

History

History
67 lines (47 loc) · 2.84 KB

sql-statement-show-histograms.md

File metadata and controls

67 lines (47 loc) · 2.84 KB
title summary aliases
SHOW STATS_HISTOGRAMS
TiDB 数据库中 SHOW HISTOGRAMS 语句的简单说明。
/docs-cn/dev/sql-statements/sql-statement-show-histograms/

SHOW STATS_HISTOGRAMS

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

语法图

ShowStmt

ShowStmt

ShowTargetFiltertable

ShowTargetFilterable

ShowLikeOrWhereOpt

ShowLikeOrWhereOpt

示例

{{< copyable "sql" >}}

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)

{{< copyable "sql" >}}

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 兼容性

SHOW STATS_HISTOGRAMS 是 TiDB 专有语法,因此不兼容 MySQL。

另请参阅