-
Notifications
You must be signed in to change notification settings - Fork 709
sql-statements: add/modify doc for SELECT, SHOW STATS_HISTOGRAMS and SHOW STATS_META
#2902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ti-srebot
merged 6 commits into
pingcap:master
from
winoros:statement-select-showhist-showstatsmeta
Jun 19, 2020
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7b69e18
sql-statements: add/modify doc for `SELECT`, `SHOW STATS_HISTOGRAMS` …
winoros 1924737
Merge branch 'master' into statement-select-showhist-showstatsmeta
yikeke 34c4fee
Apply suggestions from code review
winoros 94ed556
add an image WindowClauseOptional
ran-huang 196d11d
Update statistics.md
ran-huang c1f89e9
Merge branch 'master' into statement-select-showhist-showstatsmeta
ti-srebot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 hidden or 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,67 @@ | ||
| --- | ||
| title: SHOW STATS_HISTOGRAMS | ||
| summary: An overview of the usage of SHOW HISTOGRAMS for TiDB database。 | ||
| category: reference | ||
| --- | ||
|
|
||
| # SHOW STATS_HISTOGRAMS | ||
|
|
||
| This statement shows the histogram information collected by the `ANALYZE` statement. | ||
|
|
||
| ## Synopsis | ||
|
|
||
| **ShowStmt** | ||
|
|
||
|  | ||
|
|
||
| **ShowTargetFiltertable** | ||
|
|
||
|  | ||
|
|
||
| **ShowLikeOrWhereOpt** | ||
|
|
||
|  | ||
|
|
||
| ## Examples | ||
|
|
||
| {{< copyable "sql" >}} | ||
|
|
||
| ```sql | ||
| show stats_histograms; | ||
| ``` | ||
|
|
||
| ```sql | ||
| +---------+------------+----------------+-------------+----------+---------------------+----------------+------------+--------------+-------------+ | ||
| | 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" >}} | ||
|
|
||
| ```sql | ||
| show stats_histograms where table_name = 't2'; | ||
| ``` | ||
|
|
||
| ```sql | ||
| +---------+------------+----------------+-------------+----------+---------------------+----------------+------------+--------------+-------------+ | ||
| | 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 compatibility | ||
|
|
||
| `SHOW STATS_HISTOGRAMS` is a TiDB specific syntax, and thus not compatible with MySQL. | ||
|
|
||
| ## See also | ||
|
|
||
| * [ANALYZE](/sql-statements/sql-statement-analyze-table.md) | ||
| * [Introduction to Statistics](/statistics.md) |
This file contains hidden or 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,83 @@ | ||
| --- | ||
| title: SHOW STATS_META | ||
| summary: An overview of the usage of SHOW STATS_META for TiDB database. | ||
| category: reference | ||
| --- | ||
|
|
||
| # SHOW STATS_META | ||
|
|
||
| You can use `SHOW STATS_META` to view how many rows are in a table and how many rows are changed in that table. When using this statement, you can filter the needed information by the `ShowLikeOrWhere` clause. | ||
|
|
||
| Currently, the `SHOW STATS_META` statement outputs 6 columns: | ||
|
|
||
| | Syntax element | Description | | ||
| | -------- | ------------- | | ||
| | db_name | Database name | | ||
| | table_name | Table name | | ||
| | partition_name| Partition name | | ||
| | update_time | Last updated time | | ||
| | modify_count | The number of rows modified | | ||
| | row_count | The total row count | | ||
|
|
||
| > **注意:** | ||
| > | ||
| > The `update_time` is updated when TiDB updates the `modify_count` and `row_count` fields according to DML statements. So `update_time` is not the last execution time of the `ANALYZE` statement. | ||
|
|
||
| ## Synopsis | ||
|
|
||
| **ShowStmt** | ||
|
|
||
|  | ||
|
|
||
| **ShowTargetFiltertable** | ||
|
|
||
|  | ||
|
|
||
| **ShowLikeOrWhereOpt** | ||
|
|
||
|  | ||
|
|
||
| ## Examples | ||
|
|
||
| {{< copyable "sql" >}} | ||
|
|
||
| ```sql | ||
| show stats_meta; | ||
| ``` | ||
|
|
||
| ```sql | ||
| +---------+------------+----------------+---------------------+--------------+-----------+ | ||
| | Db_name | Table_name | Partition_name | Update_time | Modify_count | Row_count | | ||
| +---------+------------+----------------+---------------------+--------------+-----------+ | ||
| | test | t0 | | 2020-05-15 16:58:00 | 0 | 0 | | ||
| | test | t1 | | 2020-05-15 16:58:04 | 0 | 0 | | ||
| | test | t2 | | 2020-05-15 16:58:11 | 0 | 0 | | ||
| | test | s | | 2020-05-22 19:46:43 | 0 | 0 | | ||
| | test | t | | 2020-05-25 12:04:21 | 0 | 0 | | ||
| +---------+------------+----------------+---------------------+--------------+-----------+ | ||
| 5 rows in set (0.00 sec) | ||
| ``` | ||
|
|
||
| {{< copyable "sql" >}} | ||
|
|
||
| ```sql | ||
| show stats_meta where table_name = 't2'; | ||
| ``` | ||
|
|
||
| ```sql | ||
| +---------+------------+----------------+---------------------+--------------+-----------+ | ||
| | Db_name | Table_name | Partition_name | Update_time | Modify_count | Row_count | | ||
| +---------+------------+----------------+---------------------+--------------+-----------+ | ||
| | test | t2 | | 2020-05-15 16:58:11 | 0 | 0 | | ||
| +---------+------------+----------------+---------------------+--------------+-----------+ | ||
| 1 row in set (0.00 sec) | ||
| ``` | ||
|
|
||
| ## MySQL compatibility | ||
|
|
||
| `SHOW STATS_META` is a TiDB specific syntax, and thus not compatible with MySQL. | ||
|
|
||
| ## See also | ||
|
|
||
| * [ANALYZE](/sql-statements/sql-statement-analyze-table.md) | ||
| * [Introduction to Statistics](/statistics.md) |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.