'Does a sort on a mongo cursor gurantee that the cursor will not return duplicates?
Mongo docs on Read Isolation, Consistency, and Recency say that interleaving operations can cause an open cursor to return the same document more than once. However, from reading more on the topic I gathered that if I open a cursor with a sort on a field that will not to change (e.g. _id) that will guarantee that the cursor will not return any documents multiple times. Is that correct?
var cursor = db.Results
.find({"SurveyId":UUID("199CD51D-371F-47FA-B860-D25F82EC7A2B")})
.sort( { "_id": 1 } )
.batchSize(300);
cursor.forEach(function(x) { print( x._id ); });
What I'm looking for is an efficient way to process all documents in the collection exactly once (I don't care if I miss documents that are being inserted while I'm iterating through the cursor).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
