From 7516255dc5c047fe9ac4c579f4aae808d65e69bb Mon Sep 17 00:00:00 2001 From: Lynn Date: Wed, 17 Jun 2020 11:50:02 +0800 Subject: [PATCH 1/3] sql-statements: update `analyze` statement --- sql-statements/sql-statement-analyze-table.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sql-statements/sql-statement-analyze-table.md b/sql-statements/sql-statement-analyze-table.md index b7e233a751cd4..9916b6a04a17b 100644 --- a/sql-statements/sql-statement-analyze-table.md +++ b/sql-statements/sql-statement-analyze-table.md @@ -1,16 +1,18 @@ --- -title: ANALYZE TABLE | TiDB SQL Statement Reference -summary: An overview of the usage of ANALYZE TABLE for the TiDB database. +title: ANALYZE | TiDB SQL Statement Reference +summary: An overview of the usage of ANALYZE for the TiDB database. category: reference aliases: ['/docs/dev/reference/sql/statements/analyze-table/'] --- -# ANALYZE TABLE +# ANALYZE -This statement updates the statistics that TiDB builds on tables and indexes. It is recommended to run `ANALYZE TABLE` after performing a large batch update or import of records, or when you notice that query execution plans are sub-optimal. +This statement updates the statistics that TiDB builds on tables and indexes. It is recommended to run `ANALYZE` after performing a large batch update or import of records, or when you notice that query execution plans are sub-optimal. TiDB will also automatically update its statistics over time as it discovers that they are inconsistent with its own estimates. +At present, TiDB collects statistical information in two ways: full collection and incremental collection, which are realized through the `ANALYZE TABLE` and `ANALYZE INCREMENTAL TABLE` statements respectively. For detailed usage of these two statements, please refer to [introduction to statistics](/statistics.md) + ## Synopsis **AnalyzeTableStmt:** @@ -64,6 +66,8 @@ mysql> EXPLAIN SELECT * FROM t1 WHERE c1 = 3; This statement is syntactically similar with MySQL. However, `ANALYZE TABLE` may take significantly longer to execute on TiDB, as internally it operates in a different manner. +MySQL does not support the `ANALYZE INCREMENTAL TABLE` statement. TiDB supports incremental collection of statistics. For usage, please refer to [incremental collection document](/statistics.md#incremental-collection). + ## See also * [EXPLAIN](/sql-statements/sql-statement-explain.md) From f60c387e275fc6f22b0e93693c81bfce5d935a8d Mon Sep 17 00:00:00 2001 From: Lynn Date: Wed, 17 Jun 2020 11:32:17 +0800 Subject: [PATCH 2/3] sql-statements: update "change column" and "begin". --- sql-statements/sql-statement-add-index.md | 1 + sql-statements/sql-statement-analyze-table.md | 12 ++++-------- sql-statements/sql-statement-begin.md | 4 +++- sql-statements/sql-statement-change-column.md | 2 ++ sql-statements/sql-statement-commit.md | 4 ++++ 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/sql-statements/sql-statement-add-index.md b/sql-statements/sql-statement-add-index.md index 7bddd00bccddc..b479a15d5766a 100644 --- a/sql-statements/sql-statement-add-index.md +++ b/sql-statements/sql-statement-add-index.md @@ -67,6 +67,7 @@ mysql> EXPLAIN SELECT * FROM t1 WHERE c1 = 3; ## MySQL compatibility * `FULLTEXT`, `HASH` and `SPATIAL` indexes are not supported. +* `VISIBLE/INVISIBLE` index is not supported (currently only the master branch actually supports this feature). * Descending indexes are not supported (similar to MySQL 5.7). * Adding multiple indexes at the same time is currently not supported. * Adding the primary key constraint to a table is not supported by default. You can enable the feature by setting the `alter-primary-key` configuration item to `true`. For details, see [alter-primary-key](/tidb-configuration-file.md#alter-primary-key). diff --git a/sql-statements/sql-statement-analyze-table.md b/sql-statements/sql-statement-analyze-table.md index 9916b6a04a17b..b7e233a751cd4 100644 --- a/sql-statements/sql-statement-analyze-table.md +++ b/sql-statements/sql-statement-analyze-table.md @@ -1,18 +1,16 @@ --- -title: ANALYZE | TiDB SQL Statement Reference -summary: An overview of the usage of ANALYZE for the TiDB database. +title: ANALYZE TABLE | TiDB SQL Statement Reference +summary: An overview of the usage of ANALYZE TABLE for the TiDB database. category: reference aliases: ['/docs/dev/reference/sql/statements/analyze-table/'] --- -# ANALYZE +# ANALYZE TABLE -This statement updates the statistics that TiDB builds on tables and indexes. It is recommended to run `ANALYZE` after performing a large batch update or import of records, or when you notice that query execution plans are sub-optimal. +This statement updates the statistics that TiDB builds on tables and indexes. It is recommended to run `ANALYZE TABLE` after performing a large batch update or import of records, or when you notice that query execution plans are sub-optimal. TiDB will also automatically update its statistics over time as it discovers that they are inconsistent with its own estimates. -At present, TiDB collects statistical information in two ways: full collection and incremental collection, which are realized through the `ANALYZE TABLE` and `ANALYZE INCREMENTAL TABLE` statements respectively. For detailed usage of these two statements, please refer to [introduction to statistics](/statistics.md) - ## Synopsis **AnalyzeTableStmt:** @@ -66,8 +64,6 @@ mysql> EXPLAIN SELECT * FROM t1 WHERE c1 = 3; This statement is syntactically similar with MySQL. However, `ANALYZE TABLE` may take significantly longer to execute on TiDB, as internally it operates in a different manner. -MySQL does not support the `ANALYZE INCREMENTAL TABLE` statement. TiDB supports incremental collection of statistics. For usage, please refer to [incremental collection document](/statistics.md#incremental-collection). - ## See also * [EXPLAIN](/sql-statements/sql-statement-explain.md) diff --git a/sql-statements/sql-statement-begin.md b/sql-statements/sql-statement-begin.md index 0711f337a4367..b378ba3be760d 100644 --- a/sql-statements/sql-statement-begin.md +++ b/sql-statements/sql-statement-begin.md @@ -35,10 +35,12 @@ Query OK, 0 rows affected (0.01 sec) ## MySQL compatibility -This statement is understood to be fully compatible with MySQL. Any compatibility differences should be [reported via an issue](/report-issue.md) on GitHub. +TiDB can carry the option of `PESSIMISTIC` or `OPTIMISTIC` when executing the `BEGIN` statement to indicate the type of transaction this statement opens. ## See also * [COMMIT](/sql-statements/sql-statement-commit.md) * [ROLLBACK](/sql-statements/sql-statement-rollback.md) * [START TRANSACTION](/sql-statements/sql-statement-start-transaction.md) +* [TiDB optimistic transaction model](/optimistic-transaction.md) +* [TiDB pessimistic transaction model](/pessimistic-transaction.md) diff --git a/sql-statements/sql-statement-change-column.md b/sql-statements/sql-statement-change-column.md index ab37ee803540f..7645ecfefd43f 100644 --- a/sql-statements/sql-statement-change-column.md +++ b/sql-statements/sql-statement-change-column.md @@ -65,6 +65,8 @@ ERROR 1105 (HY000): can't run multi schema change * Making multiple changes in a single `ALTER TABLE` statement is not currently supported. * Only certain types of data type changes are supported. For example, an `INTEGER` to `BIGINT` is supported, but the reverse is not possible. Changing from an integer to a string format or blob is not supported. +* Modifying precision of type `DECIMAL` is not supported. +* Changing the `UNSIGNED` attribute is not supported. ## See also diff --git a/sql-statements/sql-statement-commit.md b/sql-statements/sql-statement-commit.md index 5f2b5d31a29eb..91578446b9cf1 100644 --- a/sql-statements/sql-statement-commit.md +++ b/sql-statements/sql-statement-commit.md @@ -17,6 +17,10 @@ In the absence of a `BEGIN` or `START TRANSACTION` statement, the default behavi ![CommitStmt](/media/sqlgram/CommitStmt.png) +**CompletionTypeWithinTransaction:** + +![CompletionTypeWithinTransaction](/media/sqlgram/CompletionTypeWithinTransaction.png) + ## Examples ```sql From 702428faf2e02a809c84bcdeea6445254d01761a Mon Sep 17 00:00:00 2001 From: Lynn Date: Wed, 17 Jun 2020 20:51:16 +0800 Subject: [PATCH 3/3] sql-statement: address comments --- sql-statements/sql-statement-begin.md | 2 +- sql-statements/sql-statement-change-column.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sql-statements/sql-statement-begin.md b/sql-statements/sql-statement-begin.md index b378ba3be760d..ebbc9f9a2bbb8 100644 --- a/sql-statements/sql-statement-begin.md +++ b/sql-statements/sql-statement-begin.md @@ -35,7 +35,7 @@ Query OK, 0 rows affected (0.01 sec) ## MySQL compatibility -TiDB can carry the option of `PESSIMISTIC` or `OPTIMISTIC` when executing the `BEGIN` statement to indicate the type of transaction this statement opens. +You can add the `PESSIMISTIC` or `OPTIMISTIC` option to the `BEGIN` statement in TiDB to indicate the type of transaction that this statement starts. ## See also diff --git a/sql-statements/sql-statement-change-column.md b/sql-statements/sql-statement-change-column.md index 7645ecfefd43f..925e750d0682d 100644 --- a/sql-statements/sql-statement-change-column.md +++ b/sql-statements/sql-statement-change-column.md @@ -65,7 +65,7 @@ ERROR 1105 (HY000): can't run multi schema change * Making multiple changes in a single `ALTER TABLE` statement is not currently supported. * Only certain types of data type changes are supported. For example, an `INTEGER` to `BIGINT` is supported, but the reverse is not possible. Changing from an integer to a string format or blob is not supported. -* Modifying precision of type `DECIMAL` is not supported. +* Modifying precision of the `DECIMAL` type is not supported. * Changing the `UNSIGNED` attribute is not supported. ## See also