We are using a copy of mongo, with about 150 million records in one collection, [size = 10 GB, storage size = 3.4 GB, total index size: 6 GB]
Because it is a saved historical record, we used remove to delete the record 30 days ago (about 2 million), but found that the index size increased from 6GB to 9GB.
How to delete the historical records correctly?
In general, no special operation is required for deletion. The Btree used by MongoDB is also self-balanced and does not need to be rebuilt, except for a bug in versions 3.0.7 and earlier.SERVER-21063I have not heard of anything special to pay attention to except that it will affect the balance of btree.
The increase from 6G to 9G has never been heard of. We can see if the same is true for slave nodes. If possible, for verification purposes, you can delete an index from the node and recreate it to see if the size is different.
Edit: You can try it before tryingcompactSee if it works. Pay attention to the impact on the instance, it is better to dismantle a secondary and test it separately.