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

Add a new method to "quickly jump" documents in a cursor (that has been skipped and already iterated).

    • Type: Icon: New Feature New Feature
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.0.4
    • Component/s: Querying
    • Labels:

      Add a new method to "quickly jump" documents in a cursor (that has been skipped and already iterated).

      This might be done either allowing to invoke skip() twice (in a way that the second time it starts skipping from current position) or providing a method similar to next() that does not actually return data (at least avoiding network traffic between MongoDB and the client).

      The usage scenario is the following:

      We have a huge collection and created a cursor skipping N documents (being N big, say 10 millions). We retrieve some documents, and now we need to jump another M documents.

      We have two options:
      1- Create another cursor and skipping it N+M times;
      2- Invoke next() M times on the original cursor.

      Being N big, option 1 results slow.

      On the other side, next() is less efficient than skip() to "just jump" documents. Our tests suggest that using next() M times (option 2) is worthwhile only if M is less than 10% of N.

      I'm from the RESTHeart team (http://restheart.org), and we met this need implementing a DBCursor Pool to speedup queries on collections (that already speedups things up to 1000% according to performance tests).

      For some reference about the idea, have a look at: https://softinstigate.atlassian.net/wiki/x/h4CM

      Performance test results:
      https://softinstigate.atlassian.net/wiki/x/gICM

      For some code:
      https://github.com/SoftInstigate/restheart/blob/develop/src/main/java/org/restheart/db/DBCursorPool.java

            Assignee:
            Unassigned Unassigned
            Reporter:
            uji Andrea Di Cesare
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: