[JAVA-1527] Performance of first() could be improved Created: 29/Oct/14  Updated: 01/Apr/16  Resolved: 04/Nov/14

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

Type: Bug Priority: Major - P3
Reporter: Trisha Gee Assignee: Ross Lawley
Resolution: Done Votes: 0
Labels: rc
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Performance testing has shown that the new first() method on the CRUD API is not very performant if there are documents in the database that match the search criteria but are not needed.

For example:

result = collection.find().first();

Will fetch all the first batch of results from the server, when the user only really wants the first one.

I suggest the "first" method adds a limit to bring the performance up to something more inline with the 2.x driver.



 Comments   
Comment by Jeffrey Yemin [ 31/Mar/15 ]

Closing all resolved 3.0.0 issues, as 3.0.0 has been tagged and released.

Comment by Githook User [ 30/Jan/15 ]

Author:

{u'username': u'rozza', u'name': u'Ross Lawley', u'email': u'ross.lawley@gmail.com'}

Message: Set limit(-1) for findOperations when using first() in OperationIterable

Performance improvement for find().first() scenarios.
JAVA-1527
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/45aa99d3aa3718cdfab48e72f115c3414bb258fe

Comment by Githook User [ 04/Nov/14 ]

Author:

{u'username': u'rozza', u'name': u'Ross Lawley', u'email': u'ross.lawley@gmail.com'}

Message: Set limit(-1) for findOperations when using first() in OperationIterable

Performance improvement for find().first() scenarios.
JAVA-1527
Branch: 3.0.x
https://github.com/mongodb/mongo-java-driver/commit/45aa99d3aa3718cdfab48e72f115c3414bb258fe

Generated at Thu Feb 08 08:54:50 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.