Principles of TiDB Mechanism

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

Original topic: TiDB机制原理

| username: TiDBer_CkS2lbTx

TiDB uses the LSM-tree mechanism for writes, and during a delete operation, it inserts a delete record. So, does this mean that the old data is not actually deleted and still occupies storage space?

| username: residentevil | Original post link

In the short term, it does occupy space, but after the LSMT triggers the compaction mechanism [SST file], the space will be released.

| username: hey-hoho | Original post link

Yes, regarding this principle, I recommend taking a look at:

| username: TiDBer_CkS2lbTx | Original post link

So it means that the old data is eventually reclaimed by the GC’s garbage collection?

| username: hey-hoho | Original post link

GC trigger + RocksDB Compaction ultimately releases space

| username: 饭光小团 | Original post link

Yes, GC and Compaction will handle this issue.

| username: YuchongXU | Original post link

There will be garbage collection.

| username: DBAER | Original post link

Yes, GC will reclaim.

| username: 烂番薯0 | Original post link

It won’t be deleted directly. Check the GC configuration time, which is 10 minutes by default.

| username: 小于同学 | Original post link

There is GC.

| username: zhanggame1 | Original post link

The delete operation will insert a new key, and the GC will notify RocksDB which keys can be deleted. RocksDB will execute compaction to reorganize the data, and the key-values marked for deletion will be removed.

| username: 这里介绍不了我 | Original post link

This article is very insightful, I learned a lot.

| username: opkcloud | Original post link

The TiDB GC mechanism will clean up old data that is no longer needed.

| username: TiDBer_rvITcue9 | Original post link

The default GC cleans up after 10 minutes.

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.