Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: TiDB delete数据报错
[TiDB Usage Environment] Production environment, testing
[TiDB Version] v5.1.0
[Encountered Problem] Deleting redundant data in production reports the following error?
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.
How to set txn-total-size-limit?
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.
server_configs:
tidb:
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.
The transaction is too large.
It is still recommended to write a script in Python for production, deleting 5000 rows at a time in a loop.