Questions about Manual Compaction

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

Original topic: 关于手工compact的问题

| username: zhanggame1

[Test of TiDB Usage Environment]
I tested manual compaction.
First, I created a table and inserted millions of rows of data, then deleted all the data.
After the GC time passed,
I executed manual compaction:

ctl tikv --host compact -d kv --bottommost force
store:"" compact db:Kv cf:default range:[[], []) success!

After some time, I observed the regions of the table and found no significant changes. How can I check the effects of the compaction?

The default GC is 10 minutes, and it seems it hasn’t been executed.

| username: h5n1 | Original post link

The reduction in the number of regions relies on the merge region operation, where the system merges adjacent regions that meet a certain threshold. Compaction is the process of cleaning up tombstone data after GC, reducing the size of the LSM tree, provided that GC has been performed.

| username: zhanggame1 | Original post link

Got it, according to the documentation, region merge requires the region count to be more than 1 by default.

| username: zhanggame1 | Original post link

There is another question. Currently, it seems that all data in this table has been deleted, but the size of each region has not decreased. An hour has passed since the GC time. How is the size of the region determined?

| username: tidb菜鸟一只 | Original post link

The default merge schedule setting is relatively low, which may result in a slower merge speed for the cluster. You can adjust this parameter to speed up region merge:
config set merge-schedule-limit 8

| username: h5n1 | Original post link

The region size seen in the system is an estimated value. Let’s wait a bit longer; this value should decrease.

| username: redgame | Original post link

Got it.

| username: zhanggame1 | Original post link

The size of the region is an estimated value. It should drop to 0 after a table is deleted, but currently, after a few days, it has only decreased partially and is still not below the 20m merge region condition.

| username: zhanggame1 | Original post link

Although all the data in this table has been deleted, the size of the regions is still above 20MB, so merging has not been triggered.

| username: system | Original post link

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