Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-1527

Performance of first() could be improved

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.0.0
    • Affects Version/s: None
    • Component/s: Performance
    • Labels:

      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.

            Assignee:
            ross@mongodb.com Ross Lawley
            Reporter:
            trisha.gee@10gen.com Trisha Gee
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: