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

Reduce performance impact of DocumentSourceCursor batching

    • Query Execution
    • Query 2017-05-29

      On a large collection with index on "orderdate" compare find and equivalent aggregate first batches:

      command: find { find: "orders", filter: { orderdate: { $gte: new Date(759024000000) } }, sort: { orderdate: -1.0 }, projection: { _id: 0.0, orderdate: 1.0 } } planSummary: IXSCAN { orderdate: 1 } cursorid:53712819499 keysExamined:101 docsExamined:0 numYields:0 nreturned:101 reslen:2903  0ms
      command: aggregate { aggregate: "orders", pipeline: [ { $match: { orderdate: { $gte: new Date(759024000000) } } }, { $sort: { orderdate: -1.0 } }, { $project: { _id: 0.0, orderdate: 1.0 } } ], cursor: {} } planSummary: IXSCAN { orderdate: 1 } cursorid:52250968997 keysExamined:20972 docsExamined:0 numYields:163 nreturned:101 reslen:2903 11ms
      

      The main performance difference seems to come from keysExamined which is 101 in case of find and equal to I'm not sure what in the second case (there are 2406 distinct orderdate values, collection size is 1500000 and this filter reduces it to 1034289 documents).

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            asya.kamsky@mongodb.com Asya Kamsky
            Votes:
            0 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated: