Issues with TiDB Space Usage

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

Original topic: tidb使用空间问题

| username: TiDBer_zWsmzAL8

Demand Feedback
Please clearly and accurately describe the problem scenario, desired behavior, and background information to facilitate timely follow-up by the product team.
[Problem Scenario Involved in the Demand]
We hope to make the space usage of TiDB, files, or other components transparent, including the space used by TiDB, deleted space, and reclaimable space. It would be helpful to have a view for easy querying. Thank you.
[Expected Desired Behavior]

[Alternative Solutions]

[Background Information]
For example, which users will benefit from this, and some usage scenarios. Any API design, models, or diagrams would be helpful.

| username: wenyi | Original post link

There are too many things to optimize in TiDB, such as reporting errors when a single SQL exceeds memory limits and resolving this by temporarily writing data to disk. These high-priority needs have not been implemented yet. This need is not as important as the need for reporting errors when SQL exceeds memory limits, so it can probably wait.

| username: Kongdom | Original post link

The used space and the reclaimable space are understandable. How is the deleted space calculated?

| username: TiDBer_zWsmzAL8 | Original post link

It’s similar to MySQL fragmentation.

| username: zhanggame1 | Original post link

Deleting does not release physical space. You can estimate the physical usage by summing up the size of the table’s regions and then factoring in the compression ratio.

| username: Kongdom | Original post link

:thinking: I feel like you’re talking about reclaimable space.

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

I think there should be a Grafana monitoring item to display how many keys each TiKV currently has, how many of them are marked for deletion but have not been garbage collected, and how many need to be compacted and cleaned up. Or do you know the current method?