Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-14661

Overhead of range scans

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Major - P3
    • Resolution: Works as Designed
    • 2.6.3
    • None
    • Querying
    • None

    Description

      db.foo.drop();
       
      var filler = '';
      for(c=0;c < 100; c++) {
          filler += 'a';
      }
        
      for( i =0; i < 100000; i++) {
          db.foo.insert({ "n" : Math.floor(100 * Math.random()), "fill" : filler} );
      }
       
      > db.foo.find().explain()
      {
              "cursor" : "BasicCursor",
              "isMultiKey" : false,
              "n" : 100000,
              "nscannedObjects" : 100000,
              "nscanned" : 100000,
              "nscannedObjectsAllPlans" : 100000,
              "nscannedAllPlans" : 100000,
              "scanAndOrder" : false,
              "indexOnly" : false,
              "nYields" : 781,
              "nChunkSkips" : 0,
              "millis" : 15,
              "server" : "skye.local:27017",
              "filterSet" : false
      }
      > db.foo.find({n:{$gte:0}}).explain()
      {
              "cursor" : "BasicCursor",
              "isMultiKey" : false,
              "n" : 100000,
              "nscannedObjects" : 100000,
              "nscanned" : 100000,
              "nscannedObjectsAllPlans" : 100000,
              "nscannedAllPlans" : 100000,
              "scanAndOrder" : false,
              "indexOnly" : false,
              "nYields" : 781,
              "nChunkSkips" : 0,
              "millis" : 39,
              "server" : "skye.local:27017",
              "filterSet" : false
      }

      In the test above, both queries return the same amount of documents, but looks like the overheard of the range comparison is unexpectedly high. Opening a ticket to see if there's some optimization we can do here.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              ramon.fernandez@mongodb.com Ramon Fernandez Marina
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: