How to free up DiskSpace after deleting a document

Deleted unnecessary documents as disk space is about to reach its limit.

However, DiskSpace has not decreased.
LOGICAL DATA SIZE and TOTAL DOCUMENTS in the collection have decreased, but STORAGE SIZE and INDEXES TOTAL SIZE have not decreased.

It seems that I can free up DiskSpace by optimizing storage using the compact operation.

However, the cost is a bit high and I am looking for an easier way to achieve this.

Is there any other way to free up DiskSpace other than the compact operation?

Cluster Information
MongoDB Version: 5.0.23

Is there any other way to free up DiskSpace other than the compact operation?

Since the WiredTiger Storage Engine is append-only the only way to reclaim space is by either running compact (see Identifying and Reclaiming Disk Space in MongoDB | ALEX BEVILACQUA for more info), or if you have a replica set resyning the members of the replica set to recreate the data files.

Thank you very much.

Is it possible to prevent access to clusters that are running compact()?

I think the performance of queries thrown to that cluster while the index is being rebuilt by comapct() will be significantly reduced, am I correct in my understanding?

It’s not really possible to do this. Note that the compact command’s blocking behavior has changed over time (see documentation) so the performance impact should be minimal.

If running replicasets
I believe you should be able to step up/step down a node, compact the secondaries, and rotate in and out to be primary so that way your “Primary” is not affected?

If you are managing the replica set yourself then yes, but in Atlas most replication commands are restricted.

Thanks for the reply.

I’m thinking that a cluster that is running compact() will obviously have lower query performance.

Because compact() rebuilds the indexes.