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

Optimize $sample+$project

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • None
    • Query

      When performing a pipeline doing a sample then project I noticed it was much slower than doing a project then sample. Could this be optimized? In a similar fashion as to: https://docs.mongodb.com/manual/core/aggregation-pipeline-optimization

      For example with the MovieLens dataset ~1million documents:

      Pipeline: $sample + $project _id: 76120 ms
      Pipeline: $project _id + $sample: 1124 ms

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            ross@mongodb.com Ross Lawley
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: