I deleted ~4 million documents from a MongoDB collection. Resulting Stats which I noticed were a bit shocking.
Original DB Stats :-
DataSize - 20GB StorageSize - 6.6GB Available for reuse - 2MB TotalIndexSize - 3.24GB
After deleteMany() Stats :-
DataSize - 0.24GB StorageSize - 8.6GB Available for reuse - 8.5GB TotalIndexSize - 6.29GB
I understand that mongoDB does not give up storage size after delete, you need to perform further operations like repair database, compact etc on it. But in my scenario storage size does not remain the same, it increases.
Note - Storage engine used is wired tiger.
Can anyone explain why is this happening ?
Try (source):