Sunday, 11 August 2013

Optimizing delete queries in MongoDB using the "justOne" keyword

Optimizing delete queries in MongoDB using the "justOne" keyword

I was wondering if the justOne keyword helps the speed of a remove query
even if you are querying by a unique field (i.e. there is only one
instance of the document).
For instance using pymongo:
for id in list_of_ids:
db.remove({"_id":id})
Does it still speed up the query if I use the justOne argument?
for id in list_of_ids:
db.remove({"_id":id},justOne=True)
It wouldn't make sense, but I don't know if mongo is smart enough to know
that this is the unique id so of course there will only be one.
J

No comments:

Post a Comment