deleteMany : delete large number of documents not working

I have a collection for inserting the log for certain operation. We have a TTL for 30 days. Still the number is documents that are inserted into the collection is large. So we have an option to delete all logs. Currently we have some 49K documents (~42369KB) size. While deleting using deleteMany(), documents are not deleting from the collection.

Is there any limit for deleteMany opertion?

I am not aware of such a limit. Most likely your query is wrong and documents that are not deleted do not match your query. Please share your query and some undeleted documents.

Another pisibility is that you are writing new documents while the deleteMany is running and new documents are not considered for deleting. I do not know enough about the internals to confirm if this is a real posibility.

Finally, it could be that you reach Atlas cluster limits that slows down the deleteMany to make you think that documents are not deleted. But, I think you would get a timeout error if that would be the case.

Hi @steevej, we were using the Azure Cosmosdb for Mongo API, what really happened is that, during the bulk delete, it is well over the allotted RU’s(Request Unit). That is the reason we were not able to delete all records at a time. So based on the RU’s we are doing batch-wise delete.

1 Like