-
Type:
Question
-
Resolution: Done
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
summarize
When I was using Mongo Driver Java 4.9, I checked everything and when I iterated, it took two seconds for ten thousand pieces of data, which was too slow
How to reproduce
I used the collection. find() method and returned the FindIterable<Document>class. I used the iterator() method in this class to iterate and queried 10000 pieces of data. The results were converted for two seconds, and I will paste the code out
Public static List<Map<String, Object>>convertDocumentToMap (FindIterable<Document>iterable, Integer count){ Long queryAction=System. currentTimeMillis(); System. out. println ("Creation start time:"+queryAction); List<Map<String, Object>>resultList=new ArrayList<>(count); Long queryEnd=System. currentTimeMillis(); System. out. println ("Creation end time:"+queryEnd); System. out. println ("Creation time:"+(queryEnd queryAction)); Try (MongoCursor<Document>cursor=iterable. iterator()){ Long action=System. currentTimeMillis(); System. out. println ("Cycle start time:"+action); While (cursor. hasNext()) {resultList. add (cursor. next());} Long end=System. currentTimeMillis(); System. out. println ("Loop end time:"+end); System. out. println ("Loop time:"+(end action)); } Return resultList; }