We are using morphia 0.99 and java driver 2.7.3 I would like to learn is there any difference between fetching records one by one using fetch
and retrieving results by asList (assume that there is enough memory to retrieve records through asList
).
We iterate over a large collection, while using fetch
I sometimes encounter cursor not found exception
on the server during the fetch operation, so I need to execute another command to continue, what could be the reason for this?
1-)fetch the record
2-)do some calculation on it
3-)+save it back to database again
4-)fetch another record and repeat the steps until there isn't any more records.
So which one would be faster? Fetching records one by one or retrieving bulks of results using asList, or isn't there any difference between them using morphia implementation?
Thanks for the answers
Judging from the source-code, asList()
uses fetch()
and aggregates the results for you, so I can't see much difference between the two.