From f71847c052e95f0cd34edc16712b39d0c85ae6fa Mon Sep 17 00:00:00 2001 From: Yiding Cui Date: Fri, 19 Jun 2020 11:48:11 +0800 Subject: [PATCH] cherry pick #2902 to release-4.0 Signed-off-by: ti-srebot --- TOC.md | 2 + media/sqlgram/ShowLikeOrWhereOpt.png | Bin 7022 -> 6656 bytes sql-statements/sql-statement-select.md | 6 ++ .../sql-statement-show-histograms.md | 67 ++++++++++++++ .../sql-statement-show-stats-meta.md | 83 ++++++++++++++++++ statistics.md | 4 +- 6 files changed, 159 insertions(+), 3 deletions(-) create mode 100644 sql-statements/sql-statement-show-histograms.md create mode 100644 sql-statements/sql-statement-show-stats-meta.md diff --git a/TOC.md b/TOC.md index 94a16172d8988..63f3956677b26 100644 --- a/TOC.md +++ b/TOC.md @@ -287,6 +287,8 @@ + [`SHOW [FULL] PROCESSSLIST`](/sql-statements/sql-statement-show-processlist.md) + [`SHOW PUMP STATUS`](/sql-statements/sql-statement-show-pump-status.md) + [`SHOW SCHEMAS`](/sql-statements/sql-statement-show-schemas.md) + + [`SHOW STATS_HISTOGRAMS`](/sql-statements/sql-statement-show-histograms.md) + + [`SHOW STATES_META`](/sql-statements/sql-statement-show-stats-meta.md) + [`SHOW STATUS`](/sql-statements/sql-statement-show-status.md) + [`SHOW TABLE NEXT_ROW_ID`](/sql-statements/sql-statement-show-table-next-rowid.md) + [`SHOW TABLE REGIONS`](/sql-statements/sql-statement-show-table-regions.md) diff --git a/media/sqlgram/ShowLikeOrWhereOpt.png b/media/sqlgram/ShowLikeOrWhereOpt.png index c1ec7efaf56ac8211df5f532f2c45f12d54b96c0..f68b2d4c1a598e091e4ca33cfbde74a3d3ce1724 100644 GIT binary patch delta 6581 zcmZXZWl&sAxNh;mHNk_sObAW_1O^)hcY?bG9bCdNxNGnP7(U$HT>=4uCpf{~-8tk| zow`5H^S68V?(TYP_gcG;1Oxcv$*|QhF_4guZt~ZN66m2Y3LSZANlmZ$Lqi+`rMai) zL)Q$5+xTE-g`Z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j-+yksg8x@-NnDTo!ssEu1NRot7cf7z7 zt6L7`EeJp3?bbWg6s^|#CmmA5BgT6~psNgL!09l*0z$k6Nbd%nzq3F74?|N{(2)Nj HXAb`_4O@Ms diff --git a/sql-statements/sql-statement-select.md b/sql-statements/sql-statement-select.md index 9643cc4d020d1..cb871aa313cb6 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -59,10 +59,15 @@ The `SELECT` statement is used to read data from TiDB. ![SelectLockOpt](/media/sqlgram/SelectLockOpt.png) +**WindowClauseOptional** + +![WindowClauseOptional](/media/sqlgram/WindowClauseOptional.png) + ## Description of the syntax elements |Syntax Element|Description| |:--------------------- | :-------------------------------------------------- | +|`TableOptimizerHints`| This is the hint to control the behavior of TiDB's optimizer. For more information, refer to [Optimizer Hints](/optimizer-hints.md). | |`ALL`, `DISTINCT`, `DISTINCTROW` | The `ALL`, `DISTINCT`/`DISTINCTROW` modifiers specify whether duplicate rows should be returned. ALL (the default) specifies that all matching rows should be returned.| |`HIGH_PRIORITY` | `HIGH_PRIORITY` gives the current statement higher priority than other statements. | |`SQL_CALC_FOUND_ROWS`| To guarantee compatibility with MySQL, TiDB parses this syntax, but will ignore it. | @@ -75,6 +80,7 @@ The `SELECT` statement is used to read data from TiDB. |`HAVING where_condition` | The `HAVING` clause and the `WHERE` clause are both used to filter the results. The `HAVING` clause filters the results of `GROUP BY`, while the `WHERE` clause filter the results before aggregation. | |`ORDER BY` | The `ORDER BY` clause is used to sort the data in ascending or descending order, based on columns, expressions or items in the `select_expr` list.| |`LIMIT` | The `LIMIT` clause can be used to constrain the number of rows. `LIMIT` takes one or two numeric arguments. With one argument, the argument specifies the maximum number of rows to return, the first row to return is the first row of the table by default; with two arguments, the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return.| +|`Window window_definition`| This is the syntax for window function, which is usually used to do some analytical computation. For more information, refer to [Window Function](/functions-and-operators/window-functions.md). | | `FOR UPDATE` | The `SELECT FOR UPDATE` clause locks all the data in the result sets to detect concurrent updates from other transactions. Data that match the query conditions but do not exist in the result sets are not read-locked, such as the row data written by other transactions after the current transaction is started. TiDB uses the [Optimistic Transaction Model](/optimistic-transaction.md). The transaction conflicts are not detected in the statement execution phase. Therefore, the current transaction does not block other transactions from executing `UPDATE`, `DELETE` or `SELECT FOR UPDATE` like other databases such as PostgreSQL. In the committing phase, the rows read by `SELECT FOR UPDATE` are committed in two phases, which means they can also join the conflict detection. If write conflicts occur, the commit fails for all transactions that include the `SELECT FOR UPDATE` clause. If no conflict is detected, the commit succeeds. And a new version is generated for the locked rows, so that write conflicts can be detected when other uncommitted transactions are being committed later. When using pessimistic transaction model, the behavior is basically the same as other databases. Refer to [Difference with MySQL InnoDB](/pessimistic-transaction.md#difference-with-mysql-innodb) to see the details. | |`LOCK IN SHARE MODE` | To guarantee compatibility, TiDB parses these three modifiers, but will ignore them. | diff --git a/sql-statements/sql-statement-show-histograms.md b/sql-statements/sql-statement-show-histograms.md new file mode 100644 index 0000000000000..c4c24004c7a18 --- /dev/null +++ b/sql-statements/sql-statement-show-histograms.md @@ -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** + +![ShowStmt](/media/sqlgram/ShowStmt.png) + +**ShowTargetFiltertable** + +![ShowTargetFilterable](/media/sqlgram/ShowTargetFilterable.png) + +**ShowLikeOrWhereOpt** + +![ShowLikeOrWhereOpt](/media/sqlgram/ShowLikeOrWhereOpt.png) + +## 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) diff --git a/sql-statements/sql-statement-show-stats-meta.md b/sql-statements/sql-statement-show-stats-meta.md new file mode 100644 index 0000000000000..e8b8613c6d79e --- /dev/null +++ b/sql-statements/sql-statement-show-stats-meta.md @@ -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** + +![ShowStmt](/media/sqlgram/ShowStmt.png) + +**ShowTargetFiltertable** + +![ShowTargetFilterable](/media/sqlgram/ShowTargetFilterable.png) + +**ShowLikeOrWhereOpt** + +![ShowLikeOrWhereOpt](/media/sqlgram/ShowLikeOrWhereOpt.png) + +## 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) diff --git a/statistics.md b/statistics.md index 8a887e8275d41..8d4db069a8023 100644 --- a/statistics.md +++ b/statistics.md @@ -161,7 +161,7 @@ You can view the statistics status using the following statements. You can use the `SHOW STATS_META` statement to view the total number of rows and the number of updated rows. -Syntax as follows: +The syntax of `ShowLikeOrWhereOpt` is as follows: {{< copyable "sql" >}} @@ -169,8 +169,6 @@ Syntax as follows: SHOW STATS_META [ShowLikeOrWhere] ``` -This statement returns the total number of all the rows in all the tables and the number of updated rows. You can use `ShowLikeOrWhere` to filter the information you need. - Currently, the `SHOW STATS_META` statement returns the following 6 columns: | Syntax Element | Description |