Does a DELETE operation require a document FETCH?

Hello community,

I am wondering whether a simple deleteOne requires a FETCH operation or not.

To give some more context:
Given a database cluster with a WT cache size capable of holding 100mio documents. The single collection of this cluster contains 200mio documents.

Now my application picks 100mio random documents (out of the 200mio) and updates a timestamp for each document. I’d expect to have almost all of this 100mio “touched” documents in the WT cache now.

My applications task is now to DELETE all documents with an untouched timestamp. Given an index timestamp_1__id_1 I can query for the documents _id by reading from the index only.

But what happens next, when I call a deleteOne for every _id of my queries result set? Does MongoDB FETCH the to be deleted documents into the cache, evicting all my previously touched documents I’d like to keep and work with or is no FETCH required for the delete operation?

Best,
Jens

You can see what “explain” says first.

Also use bulk write for multiple deletes and it should run faster than deleteOne.

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