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

Use a covered and streaming plan for $group, $sum:1 queries

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Backlog
    • Component/s: Aggregation Framework
    • Labels:
      None
    • Sprint:
      Query 2019-07-29
    • Case:

      Description

      A very common use of an aggregation is to count elements by group:

      db.items.aggregate([ {$group: {_id: category, count: {$sum: 1}}}])
      

      If there is an index over category, this pipeline could be covered and no document retrieval is necessary.

      Since this is a quite common pattern, you may take it into account and make use of indexes.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              backlog-query-optimization Backlog - Query Optimization
              Reporter:
              stoma Nicolas Dascanio
              Participants:
              Votes:
              10 Vote for this issue
              Watchers:
              14 Start watching this issue

                Dates

                Created:
                Updated: