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

Reorder $project to be after limits and skips

    • Type: Icon: New Feature New Feature
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • None

      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.

            Assignee:
            Unassigned Unassigned
            Reporter:
            craig.wilson@mongodb.com Craig Wilson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: