title: MongoDB very slow deleteMany and remove
body: <p>In my MongoDB with 2 replicas I have a collection with over 100 million documents, the size of the collection is over 400 GB and the indexes size is 150 GB. I have to reduce the size of the collection by removing the oldest records using <code>modifiedOn</code> field for which I have a TTL index. The TTL index will remove entries older than a month but I have to act now. I've tried to remove the oldest records using:</p>
  <pre><code>db.myCollection.deleteMany({modifiedOn : {&quot;$lt&quot; : new Date(2021, 12, 20}})
  </code></pre>
  <p>and</p>
  <pre><code>db.myCollection.remove({modifiedOn : {&quot;$lt&quot; : new Date(2021, 12, 20}})
  </code></pre>
  <p>I was trying to increment the day and then execute the query to reduce the load but it takes at least 10 hours to complete these queries. I know that dropping the collection is the fastest option but I want to preserve the latest data.</p>
  <p>Why exactly does it take so long to execute these queries even with an index for <code>modifiedOn</code>, is the index too big and updating it takes so long? What are better options to delete the oldest records?</p>