performance regression in .skip() using btree cursor

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: 2.6.0
    • Component/s: Querying
    • None
    • ALL
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      Insert some documents

      var f = 10
      var n = 100000
      
      doc = {}
      for (var i=0; i<f; i++)
          doc[i] = i
      
      db.c.drop()
      for (var i=0; i<n; i++)
          db.c.insert(doc)
      

      Skip over all but 1 using _id index, get the last:

      db.c.find().hint({_id:1}).skip(n-1).next()
      

      Performs about 2x worse in 2.6.4 than 2.4.10:

      v 2.4.10 n 100000 f 10 t 49
      v 2.6.4 n 100000 f 10 t 93
      

      The reason seems to be that mongod is fetching the skipped documents in 2.6.x but not in 2.4.x, so the ratio could be much worse if the collection doesn't fit in memory and the skipped documents must be paged in.

            Assignee:
            Ramon Fernandez Marina
            Reporter:
            Bruce Lucas (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: