[JAVA-5091] FindIterable<Document>'s iterator () method, Iterator query problem Created: 29/Jul/23  Updated: 31/Jul/23  Resolved: 31/Jul/23

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Question Priority: Major - P3
Reporter: chaoyang jia Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Documentation Changes Summary:

1. What would you like to communicate to the user about this feature?
2. Would you like the user to see examples of the syntax and/or executable code and its output?
3. Which versions of the driver/connector does this apply to?


 Description   

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;
 
}



 Comments   
Comment by Jeffrey Yemin [ 31/Jul/23 ]

Hi there, thank you for reaching out. As this sounds like a support issue, I wanted to give you some resources to get this question answered more quickly:

  • Our MongoDB support portal, located at support.mongodb.com
  • Our MongoDB community portal, located here
  • If you are an Atlas customer, you can also: Click the in-app chat icon in the lower right corner to chat with a MongoDB Support representative OR Click Support in the left-hand navigation to view Developer Resources.

Just in case you have already opened a support case and are not receiving sufficient help, please let me know and I can facilitate escalating your issue.

Thank you!

Comment by chaoyang jia [ 29/Jul/23 ]

This issue is very important to me, I need to optimize this efficiency

Comment by PM Bot [ 29/Jul/23 ]

Hi j15030047216@163.com, thank you for reporting this issue! The team will look into it and get back to you soon.

Generated at Thu Feb 08 09:03:43 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.