Error When Deleting Data in TiDB

This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: TiDB delete数据报错

| username: jingyesi3401

[TiDB Usage Environment] Production environment, testing

[TiDB Version] v5.1.0

[Encountered Problem] Deleting redundant data in production reports the following error?

| username: forever | Original post link

Exceeded the single transaction limit, try adjusting this parameter txn-total-size-limit, the default value is 104857600/100M, or add a limit and delete in batches.

| username: gary | Original post link

Try deleting in batches.

| username: jingyesi3401 | Original post link

How to set txn-total-size-limit?

| username: OnTheRoad | Original post link

The prompt is very clear:
Method 1: Use tiup cluster edit-config <cluster_name> to increase the txn-total-size-limit parameter in the TiDB configuration, which requires a restart.

    performance.txn-total-size-limit: 1073741824 # The default is 100M, you can increase this value

Method 2: Add restriction conditions, delete in batches, and reduce the data volume of a single transaction.

| username: wuxiangdong | Original post link

The transaction is too large.

| username: wuxiangdong | Original post link

It is still recommended to write a script in Python for production, deleting 5000 rows at a time in a loop.