I have a MongoDB collection with over 2.9M records and i want to remove the old data till a specific date range. & there’s only one index (i.e. _id UNIQUE) created over this collection
Upon running the following command in a shell, it is taking too much time:
"db.collection.remove({_id: {$in: db.collection.find({}, {_id : 1}).limit(100).sort({id:1}).toArray().map(function(doc) { return doc._id; }) }})
"
So which index is more suitable for a function “deleteMany or remove” to remove data from a column using a wildcard?
Secondly, i am creating a new index right now , on the same column in ASC order with option “Create index in the backgound”. How much time the index creation will take ?