Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: tidb_gc_life_time设置多大合适
[TiDB Usage Environment] Production Environment / Testing / PoC
[TiDB Version] 5.0.0
[Reproduction Path] What operations were performed when the issue occurred
[Encountered Issue: Issue Phenomenon and Impact]
What is the appropriate value to set for tidb_gc_life_time? Thank you!
[Resource Configuration]
[Attachments: Screenshots / Logs / Monitoring]
It depends on the business and the actual situation. If it’s too long, it will take up too much space. If it’s too short, a lot of historical change data might not be retrievable.
Try adjusting according to the business, but don’t make it too long, as it may cause performance issues.
What is your requirement for changing this parameter? If there is no need, don’t change it.
Overall, if there are more deletions and the focus is on recording the state, the duration should be shorter.
If there are more insertions and the focus is on recording operation logs, the duration can be longer.
It also depends on your machine’s performance.
Anyway, my machine’s performance is not great, so I set it to 10 minutes. Since I’m the only one managing this database, having a 10-20 minute flashback is generally enough to cover my own operational mistakes.
If it’s for importing data into a new database, it’s recommended to set the time longer, around 20-30 minutes. After importing the data, change it back! If the business changes frequently, 5-10 minutes should be fine. It also depends on the module node configuration, etc.
Preventing the right person from accidentally deleting data can also allow for data restoration.
That depends on your response time. Setting this time too long can affect database performance.
I see that most community users generally set it to 10 minutes.
For example:
If the maintenance personnel accidentally delete data and the business side only discovers it 2 hours later, if tidb_gc_life_time is set to 3 hours, the data can be flashed back. In this case, there will be more old versions of the data, which may result in some performance loss during queries.
It mainly depends on the business and recovery time, etc.
We set it to 1 hour. 10 minutes might result in accidental data deletion, and there might not be enough time to react or even notice it. However, it mainly depends on the data update frequency and the disk, which can somewhat impact performance. The longest I’ve seen it set to is 1 day.
Based on the requirements, I plan to set it to 24 hours or 48 hours. Our database is mainly for inserts, with few updates and no deletes, so having more MVCC copies won’t have an impact.
24 hours, that’s quite a lot. Don’t you use select? If you frequently perform range queries, it will affect performance.
The impact on select depends on the number of MVCC versions caused by update and delete. Ensuring fewer updates and deletes can solve this problem.
Sure, that works. It still depends on the business. 
I think 24 hours is appropriate, but the default is 10 minutes. It’s hard to find problems in 10 minutes.
We’ve always used the default values. When the hardware can’t keep up, setting it too long can affect performance.