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

Reorder $project to be after limits and skips

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Aggregation Framework
    • Labels:
      None

      Description

      I was looking at the optimizing aggregation pipelines docs page and didn't see this one listed.

      I don't know what the cost is to do a bunch of projections only to take the first 3 of them, but reordering the pipeline to push $project before limits and skips would remove the question.

      So:

      { $project: { a: 1, b: 1} },
      { $skip: 10 }
      

      would look like this:

      { $skip: 10 },
      { $project: {a :1, b: 1 } }
      

      In addition, doing this might allow further skip/limit coalescence to further optimize the pipeline.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              craiggwilson Craig Wilson
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: