Skip to content

feat: txn limit shift to 1TB #15363

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion develop/dev-guide-transaction-restraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,11 @@ mysql> SELECT * FROM T2;
基本原则是要限制事务的大小。TiDB 对单个事务的大小有限制,这层限制是在 KV 层面。反映在 SQL 层面的话,简单来说一行数据会映射为一个 KV entry,每多一个索引,也会增加一个 KV entry。所以这个限制反映在 SQL 层面是:

- 最大单行记录容量为 120MB(TiDB v5.0 及更高的版本可通过 tidb-server 配置项 `performance.txn-entry-size-limit` 调整,低于 TiDB v5.0 的版本支持的单行容量为 6MB)。
- 支持的最大单个事务容量为 10GB(TiDB v4.0 及更高版本可通过 tidb-server 配置项 `performance.txn-total-size-limit` 调整,低于 TiDB v4.0 的版本支持的最大单个事务容量为 100MB)。
- 事务的大小限制在不同版本受到不同参数的影响。

- 低于 TiDB v4.0 的版本支持的最大单个事务容量为 100MB。
- TiDB v4.0 及更高版本中,可通过 tidb-server 配置项 [`performance.txn-total-size-limit`](/tidb-configuration-file.md#txn-total-size-limit) 调整,默认值为 100MB,最大限制为 1TB。
- TiDB v6.5 及更高版本中,支持的单个事务容量默认受到 [memory control](/configure-memory-usage.md) 的控制,若手动设置 `performance.txn-total-size-limit` ,可以控制事务大小最大为 1 TB。
Comment on lines +719 to +720
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- TiDB v4.0 及更高版本中,可通过 tidb-server 配置项 [`performance.txn-total-size-limit`](/tidb-configuration-file.md#txn-total-size-limit) 调整,默认值为 100MB,最大限制为 1TB。
- TiDB v6.5 及更高版本中,支持的单个事务容量默认受到 [memory control](/configure-memory-usage.md) 的控制,若手动设置 `performance.txn-total-size-limit` ,可以控制事务大小最大为 1 TB
- TiDB v4.0 及更高版本中,可通过 tidb-server 配置项 [`performance.txn-total-size-limit`](/tidb-configuration-file.md#txn-total-size-limit) 调整,默认值为 `100MB`,最大限制为 `1TB`
- TiDB v6.5 及更高版本中,支持的单个事务容量默认受到 [memory control](/configure-memory-usage.md) 的控制,若手动设置 `performance.txn-total-size-limit` ,可以控制事务大小最大为 `1TB`


另外注意,无论是大小限制还是行数限制,还要考虑事务执行过程中,TiDB 做编码以及事务额外 Key 的开销。在使用的时候,为了使性能达到最优,建议每 100 ~ 500 行写入一个事务。

Expand Down