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

Java driver is 4 times slower than shell when loading data

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Won't Fix
    • Affects Version/s: 2.12.3
    • Fix Version/s: None
    • Component/s: Performance
    • Labels:
      None
    • Environment:
      MBP, 16G RAM, Single instance MongoDB 2.6.1

      Description

      First populate a test collection:

          for(var i=0;i<5000;i++) db.test.save(obj);  
          // where obj is a rich document, avg size 8KB. 

      When ran within Mongo shell:

          Date.timeFunc(function(){
               for(var i=0;i<30;i++){ db.test.find().toArray() }
          })

      Total time used: 1996ms (30 queries)
      Average time per query: 67ms

      When ran in a standard java program:

           DB db = mongoClient.getDB( "ceairdb" );
       
          DBCollection coll = db.getCollection("test");
       
          try {
              Date now = new Date(); 
              Date end = null;
              for(int k=0;k<30;k++){
                  cursor = coll.find();
                  cursor.toArray();
              } 
              end = new Date();             
          } finally {
             cursor.close();
          }

      Total time used: 8600 ms
      Average time per query: 280 ms

      Expected: Java drivers's performance should be comparable to shell version

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            jianfa.tang Jianfa Tang (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: