I am performing a simple query using Pymongo against a list of filenames:
db.FileAssets.find({'filename': {'$nin': filenames}}})
However, the query is throwing the DocumentTooLarge
error. The length of the filenames
list is 152098 and the Python object size is 1320856. Pymongo states the query is 20791219 bytes so I'm guessing that whatever MongoDB does internally to perform the $nin is overloading the doc size. What is an alternative way to perform this query?
Most likely it is about Response object. It can take too much memory in MongoDB.
Sometimes, adding new indexes can resolve this issues.