How to Adjust the GC Life Time of GC?

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

Original topic: GC的GC life time时间如何调整?

| username: yytest

Is the GC life time for garbage data collection automatically adjusted, or can it be manually adjusted? How do you set the GC life time?

| username: Jack-li | Original post link

Automatic adjustment. Haven’t tried manual adjustment.

| username: DBRE | Original post link

tidb_gc_life_time introduced from version v5.0

  • Scope: GLOBAL
  • Default value: 10m0s
  • Range: [10m0s, 8760h0m0s]
  • This variable is used to specify the time limit for retaining data during each garbage collection (GC). The variable value is in Go’s Duration string format. During each GC, the current time minus the value of this variable will be used as the safe point.

Adjust it like this: set global tidb_gc_life_time=1h

| username: Kongdom | Original post link

Some scenarios are automatically adjusted, and manual adjustments are also possible. The GC life time is a system variable that can be set using the set command.

| username: zhanggame1 | Original post link

The default GC interval and GC life are both 10 minutes. You can use the set global command to change them. By querying the mysql.tidb table, you can see the GC parameter settings and GC execution status.

| username: TiDBer_QYr0vohO | Original post link


| username: 小于同学 | Original post link


| username: TiDBer_rvITcue9 | Original post link

The tidb_gc_life_time parameter

| username: 像风一样的男子 | Original post link

There is a table mysql.tidb, you can directly update the tikv_gc_life_time field.

| username: yytest | Original post link

Thank you, teacher, for your patient explanation!

| username: Jack-li | Original post link


| username: zhaokede | Original post link

The default is 10 minutes, suitable for most scenarios.

| username: TiDBer_H5NdJb5Q | Original post link

May I ask, if an OLAP task runs for more than 10 minutes, will the GC delete data from more than 10 minutes ago when using the default configuration?

| username: Kongdom | Original post link

My understanding is that it will be deleted :thinking: