12

TIDB: transaction too large, len:300001

 4 years ago
source link: https://blog.csdn.net/oqqYuan1234567890/article/details/106248925
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

TIDB: transaction too large, len:300001

original.png
皿小草 2020-05-21 08:51:13 articleReadEyes.png 451
分类专栏: db

批量事务插入报错 transaction too large, len:300001

issue上搜索:
https://github.com/pingcap/docs-cn/issues/156
问题大概如下:

TiDB 对单个事务的大小有限制,这层限制是在 KV 层面,有如下三个限制:

单条 KV entry 不超过 6MB
KV entry 的总条数不超过 30w
KV entry 的总大小不超过 100MB
简单来说一行数据会映射为一个 KV entry,每多一个索引,也会增加一个 KV entry,所以这个限制反映在 SQL 层面是:
单行数据不大于 6MB
总的行数*(1 + 索引个数) < 30w
一次提交的所以数据小于 100MB

总的行数*(1 + 索引个数) < 30w
KV entry的计算,是需要算上索引数量的。
假如表有4个索引,那么一次事务提交的总行数不能超过6W条。

解决办法:
把大事务拆分


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK