Optimize $sample+$project

XMLWordPrintableJSON

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

      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 - Query Team (Inactive)
            Reporter:
            Ross Lawley
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: