Without sync priority or performance requirements on the task, I need to check all documents once per day and removing some of them.

The find filter is not static but can be defined within a db engine script function like function check_doc(){ }.

With .find() - no filter/condition in brackets - the function will check some non-indexed fields and decides whether the document must be removed or not.

.find().check_doc()/forEach the most effient way for iteratively checking each document, one by one, and remove justOne from there?

Furthermore, is there a variable available for checking the mongodb status, whether it is locked or sync delay (because of other queries and tasks on the DB)? If so, I'd prefer to delay the check_doc which has lowest priority. However, so far I could not find a way to decrease priority or a flag to check the status/delay.


The current version does not allow for specifying different priorities for different operations. It is likely that maintaining an index on the collection to allow this periodic process to execute much quicker than a full collection scan will give you better overall performance.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.