Can't Compact Time Series Collection


I have over 100 GB of unused disk usage (and just 7GB used) in my time series collection that isn’t being reclaimed. I am unable to compact it. When I try, I receive the error:
MongoServerError: can't compact a view

How can I reclaim this space?

Hi @Ben_Devore welcome to the community!

I think you are correct. Currently we don’t have an easy way to reclaim unused space in a time series collection. I opened SERVER-70679 to investigate further options.

In the meantime, I can suggest a couple of workarounds for this:

  1. Use mongodump and mongorestore to recreate the collection
  2. Perform initial sync from a secondary

Before doing either method on production, I strongly recommend you to test the procedure thoroughly and do a backup.

Best regards


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