From 5630af21ffa26a1f4e310e21328f00b700226b31 Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Mon, 9 Dec 2019 15:13:41 +0800 Subject: [PATCH 1/4] =?UTF-8?q?change=20"=E5=94=AF=E4=B8=80=E5=88=97"=20to?= =?UTF-8?q?=20"=E5=94=AF=E4=B8=80=E9=94=AE"=20in=20partitioning.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dev/reference/sql/partitioning.md | 2 +- v3.0/reference/sql/partitioning.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/reference/sql/partitioning.md b/dev/reference/sql/partitioning.md index 078f5372750a..bd78f0cd6e82 100644 --- a/dev/reference/sql/partitioning.md +++ b/dev/reference/sql/partitioning.md @@ -623,7 +623,7 @@ SELECT store_id, COUNT(department_id) AS c ### 分区键,主键和唯一键 -本节讨论分区键,主键和唯一键之间的关系。一句话总结它们之间的关系要满足的规则:**分区表的每个唯一列,必须包含分区表达式中用到的所有列**。 +本节讨论分区键,主键和唯一键之间的关系。一句话总结它们之间的关系要满足的规则:**分区表的每个唯一键,必须包含分区表达式中用到的所有列**。 > every unique key on the table must use every column in the table's partitioning expression. diff --git a/v3.0/reference/sql/partitioning.md b/v3.0/reference/sql/partitioning.md index 078f5372750a..bd78f0cd6e82 100644 --- a/v3.0/reference/sql/partitioning.md +++ b/v3.0/reference/sql/partitioning.md @@ -623,7 +623,7 @@ SELECT store_id, COUNT(department_id) AS c ### 分区键,主键和唯一键 -本节讨论分区键,主键和唯一键之间的关系。一句话总结它们之间的关系要满足的规则:**分区表的每个唯一列,必须包含分区表达式中用到的所有列**。 +本节讨论分区键,主键和唯一键之间的关系。一句话总结它们之间的关系要满足的规则:**分区表的每个唯一键,必须包含分区表达式中用到的所有列**。 > every unique key on the table must use every column in the table's partitioning expression. From 5f9a3132fb76764a971b774f1d2bf674909b5916 Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Tue, 10 Dec 2019 19:20:46 +0800 Subject: [PATCH 2/4] address comment --- v3.1/reference/sql/partitioning.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3.1/reference/sql/partitioning.md b/v3.1/reference/sql/partitioning.md index 078f5372750a..bd78f0cd6e82 100644 --- a/v3.1/reference/sql/partitioning.md +++ b/v3.1/reference/sql/partitioning.md @@ -623,7 +623,7 @@ SELECT store_id, COUNT(department_id) AS c ### 分区键,主键和唯一键 -本节讨论分区键,主键和唯一键之间的关系。一句话总结它们之间的关系要满足的规则:**分区表的每个唯一列,必须包含分区表达式中用到的所有列**。 +本节讨论分区键,主键和唯一键之间的关系。一句话总结它们之间的关系要满足的规则:**分区表的每个唯一键,必须包含分区表达式中用到的所有列**。 > every unique key on the table must use every column in the table's partitioning expression. From 5b6e59d2955827ba3ba47ab13c7515bd2c77f507 Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Wed, 19 Feb 2020 13:49:20 +0800 Subject: [PATCH 3/4] dev/reference/best-practices: update optimistic transaction document --- .../best-practices/optimistic-transaction.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dev/reference/best-practices/optimistic-transaction.md b/dev/reference/best-practices/optimistic-transaction.md index 3d425ea6c029..2ba9944f752f 100644 --- a/dev/reference/best-practices/optimistic-transaction.md +++ b/dev/reference/best-practices/optimistic-transaction.md @@ -103,17 +103,15 @@ COMMIT; 通过分析两阶段提交的过程,可以发现单个事务过大时会存在以下问题: * 客户端在提交之前,数据都写在内存中,而数据量过多时易导致 OOM (Out of Memory) 错误。 -* 在第一阶段写入数据时,与其他事务出现冲突的概率会指数级增长,使事务之间相互阻塞影响。 +* 在第一阶段写入数据耗时增加,与其他事务出现写冲突的概率会指数级增长。 * 最终导致事务完成提交的耗时增加。 -因此,TiDB 特意对事务的大小做了一些限制: +TiDB 对事务做了一些限制: * 单个事务包含的 SQL 语句不超过 5000 条(默认) * 每个键值对不超过 6 MB -* 键值对的总数不超过 300000 -* 键值对的总大小不超过 100 MB -为了使性能达到最优,建议每 100~500 行写入一个事务。 +为了使性能达到最优,建议每 100~500 行写入一个事务。TiDB 设置了键值对的总大小不超过 100 MB 默认限制,可以通过配置文件中的配置项 `txn-total-size-limit` 进行修改。 ## 事务冲突 @@ -122,7 +120,9 @@ COMMIT; * 读写冲突:部分事务进行读操作时,有事务在同一时间对相同的 Key 进行写操作。 * 写写冲突:不同事务同时对相同的 Key 进行写操作。 -在 TiDB 的乐观锁机制中,只有在客户端执行 `commit` 时,才会触发两阶段提交并检测是否存在写写冲突。也就是说,在乐观事务下,如果存在写写冲突,在事务提交阶段就会暴露出来,因而更容易被用户感知。 +在 TiDB 当前的事务模型下,不会出现读写冲突,所有的读操作都不会被写操作阻塞。 + +对于写写冲突,在 TiDB 的乐观锁机制中,只有在客户端执行 `commit` 时,才会触发两阶段提交并检测是否存在写写冲突。也就是说,在乐观事务下,如果存在写写冲突,只有到事务提交阶段才会暴露出来。相对而言,悲观事务则在执行过程中就会暴露。 ### 默认冲突行为 From ae9be0f164c38ad081e6dbc15691c584d7928a0d Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Wed, 19 Feb 2020 16:06:30 +0800 Subject: [PATCH 4/4] address comment --- dev/reference/best-practices/optimistic-transaction.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dev/reference/best-practices/optimistic-transaction.md b/dev/reference/best-practices/optimistic-transaction.md index 39efa09984a4..f05a16c5438f 100644 --- a/dev/reference/best-practices/optimistic-transaction.md +++ b/dev/reference/best-practices/optimistic-transaction.md @@ -111,7 +111,9 @@ TiDB 对事务做了一些限制: * 单个事务包含的 SQL 语句不超过 5000 条(默认) * 每个键值对不超过 6 MB -为了使性能达到最优,建议每 100~500 行写入一个事务。TiDB 设置了键值对的总大小不超过 100 MB 默认限制,可以通过配置文件中的配置项 `txn-total-size-limit` 进行修改。 +为了使性能达到最优,建议每 100~500 行写入一个事务。 + +TiDB 设置了键值对的总大小不超过 100 MB 默认限制,可以通过配置文件中的配置项 `txn-total-size-limit` 进行修改,最大支持到 10GB。实际的单个事务大小限制还取决于用户的内存,执行大事务时 TiDB 进程的内存消耗大约是事务大小 6 倍以上。 ## 事务冲突