How to Release Disk Space After Deleting Large Table Indexes in TiDB

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

Original topic: 删除TiDB大表索引后磁盘空间怎么释放

| username: jingyesi3401

In the production environment, the disk space is limited. I deleted a large table index, and the index usage has dropped from 3T to 1.56T, but the corresponding TiKV disk space has not been released. My GC setting is 10 minutes, and it has already exceeded 10 minutes. Should I use ALTER TABLE xxx ANALYZE; to release the disk space?

| username: h5n1 | Original post link

Normally, cleanup starts after GC, and it takes some time. If it hasn’t been cleaned for a long time, you need to check if there is an issue with GC. You can check the tidb.log file. It is most likely a bug.

| username: jingyesi3401 | Original post link

Can executing analyze table xxx; release disk space?

| username: xfworld | Original post link

The ANALYZE TABLE command can improve the accuracy of table statistics, which is essential for SQL logical and physical optimization processes, but it cannot release data.

You have to wait for GC.

| username: Raymond | Original post link

This is to recollect statistics, it cannot release disk space.


You can refer to this article

| username: h5n1 | Original post link

“analyze” is for collecting statistical information. Considering your database version, it’s highly likely a bug.

| username: jingyesi3401 | Original post link

I checked that there are no records in gc_delete_range_done, but there are records in gc_delete_range. I don’t know when gc_delete_range_done will have records; it might be due to manual operations.

| username: Raymond | Original post link

Follow this troubleshooting guide and take a look.

| username: jingyesi3401 | Original post link

The logs I found are as follows:


gc_worker.log (52.5 KB)

| username: jingyesi3401 | Original post link

The space has been released, but the release speed feels a bit slow. It was only released when I checked this morning.

| username: tidb狂热爱好者 | Original post link

Because these spaces are very likely to be reused, the release is relatively slow. Secondly, deleting on an SSD can actually affect its performance, so the deletion process will be very slow.

| username: system | Original post link

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