Skip to content

Commit

Permalink
Merge pull request pingcap#235 from CaitinChen/update-txn-limit
Browse files Browse the repository at this point in the history
Update transaction limit
  • Loading branch information
CaitinChen committed Jun 14, 2019
2 parents c5eb4fa + 82adf83 commit 5f96a73
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tidb-best-practice.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ TiDB 提供完整的分布式事务,事务模型是在 [Google Percolator](htt

由于分布式事务要做两阶段提交,并且底层还需要做 Raft 复制,如果一个事务非常大,会使得提交过程非常慢,并且会卡住下面的 Raft 复制流程。为了避免系统出现被卡住的情况,我们对事务的大小做了限制:

- 单个事务包含的 SQL 语句不超过 5000 条(默认)
- 单条 KV entry 不超过 6MB
- KV entry 的总条数不超过 30W
- KV entry 的总大小不超过 100MB
Expand Down Expand Up @@ -145,6 +146,7 @@ sync-log = true

上面提到了 TiDB 对单个事务的大小有限制,这层限制是在 KV 层面,反映在 SQL 层面的话,简单来说一行数据会映射为一个 KV entry,每多一个索引,也会增加一个 KV entry,所以这个限制反映在 SQL 层面是:

+ 单个事务包含的 SQL 语句不超过 5000 条(默认)
+ 单行数据不大于 6MB
+ 总的行数*(1 + 索引个数) < 30W
+ 一次提交的全部数据小于 100MB
Expand Down

0 comments on commit 5f96a73

Please sign in to comment.