Suppose I've got very big collection and I select it by
MongoCursor<MyClass> answer = myCollection.find().as(MyClass.class);
Will Jongo/Mongo load whole collection at the first call or incrementally load data while I will iterate over answer
?
Jongo's
MongoCursor
uses Mongo's regularDBCursor
under the hood. TheDBCursor
loads elements lazily (as typically all cursors do). I.e., your whole collection will not be loaded into memory, it will be lazily loaded while you iterate through your cursor.Relevant source from Jongo where
cursor
is aDBCursor
.