forked from pingcap/docs-cn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rehash and update statistics and SQL docs (pingcap#17827)
- Loading branch information
Showing
18 changed files
with
600 additions
and
526 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
title: SHOW COLUMN_STATS_USAGE | ||
summary: TiDB 数据库中 SHOW COLUMN_STATS_USAGE 的使用概况。 | ||
--- | ||
|
||
# SHOW COLUMN_STATS_USAGE | ||
|
||
`SHOW COLUMN_STATS_USAGE` 语句显示列统计信息的最近一次使用时间和收集时间。你还可以使用该语句来查看 `PREDICATE COLUMNS` 和已收集统计信息的列。 | ||
|
||
目前,`SHOW COLUMN_STATS_USAGE` 语句返回以下列: | ||
|
||
| 列名 | 说明 | | ||
| -------- | ------------- | | ||
| `Db_name` | 数据库名 | | ||
| `Table_name` | 表名 | | ||
| `Partition_name` | 分区名 | | ||
| `Column_name` | 列名 | | ||
| `Last_used_at` | 最近一次将列统计信息用于查询优化的时间 | | ||
| `Last_analyzed_at` | 最近一次收集列统计信息的时间 | | ||
|
||
## 语法图 | ||
|
||
```ebnf+diagram | ||
ShowColumnStatsUsageStmt ::= | ||
"SHOW" "COLUMN_STATS_USAGE" ShowLikeOrWhere? | ||
ShowLikeOrWhere ::= | ||
"LIKE" SimpleExpr | ||
| "WHERE" Expression | ||
``` | ||
|
||
## 示例 | ||
|
||
```sql | ||
SHOW COLUMN_STATS_USAGE; | ||
``` | ||
|
||
``` | ||
+---------+------------+----------------+-------------+--------------+---------------------+ | ||
| Db_name | Table_name | Partition_name | Column_name | Last_used_at | Last_analyzed_at | | ||
+---------+------------+----------------+-------------+--------------+---------------------+ | ||
| test | t1 | | id | NULL | 2024-05-10 11:04:23 | | ||
| test | t1 | | b | NULL | 2024-05-10 11:04:23 | | ||
| test | t1 | | pad | NULL | 2024-05-10 11:04:23 | | ||
| test | t | | a | NULL | 2024-05-10 11:37:06 | | ||
| test | t | | b | NULL | 2024-05-10 11:37:06 | | ||
+---------+------------+----------------+-------------+--------------+---------------------+ | ||
5 rows in set (0.00 sec) | ||
``` | ||
|
||
## MySQL 兼容性 | ||
|
||
该语句是 TiDB 对 MySQL 语法的扩展。 | ||
|
||
## 另请参阅 | ||
|
||
* [`ANALYZE`](/sql-statements/sql-statement-analyze-table.md) | ||
* [常规统计信息](/statistics.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
--- | ||
title: SHOW STATS_BUCKETS | ||
summary: TiDB 数据库中 SHOW STATS_BUCKETS 的使用概况。 | ||
--- | ||
|
||
# SHOW STATS_BUCKETS | ||
|
||
`SHOW STATS_BUCKETS` 语句显示[常规统计信息](/statistics.md)中桶的信息。 | ||
|
||
目前,`SHOW STATS_BUCKETS` 语句返回以下列: | ||
|
||
| 列名 | 说明 | | ||
| :-------- | :------------- | | ||
| `Db_name` | 数据库名 | | ||
| `Table_name` | 表名 | | ||
| `Partition_name` | 分区名 | | ||
| `Column_name` | 取决于 `Is_index` 值:`Is_index` 为 `0` 时显示列名,为 `1` 时显示索引名 | | ||
| `Is_index` | 是否是索引列 | | ||
| `Bucket_id` | 桶的 ID | | ||
| `Count` | 该桶和之前桶中所有数值的个数 | | ||
| `Repeats` | 最大值的出现次数 | | ||
| `Lower_bound` | 最小值 | | ||
| `Upper_bound` | 最大值 | | ||
| `Ndv` | 桶中不同值的数量。当 `tidb_analyze_version` = `1` 时,`Ndv` 总是 `0`,没有实际意义。 | | ||
|
||
## 语法图 | ||
|
||
```ebnf+diagram | ||
ShowStatsBucketsStmt ::= | ||
"SHOW" "STATS_BUCKETS" ShowLikeOrWhere? | ||
ShowLikeOrWhere ::= | ||
"LIKE" SimpleExpr | ||
| "WHERE" Expression | ||
``` | ||
|
||
## 示例 | ||
|
||
```sql | ||
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 语法的扩展。 | ||
|
||
## 另请参阅 | ||
|
||
* [`ANALYZE`](/sql-statements/sql-statement-analyze-table.md) | ||
* [常规统计信息](/statistics.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.