Count plans sometimes don't need a FETCH

XMLWordPrintableJSON

    • Minor Change
    • ALL
    • Query 2017-06-19
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Not sure why this is happening, but given index on username:1 match by username and group on username correctly uses covered index, but grouping on constant does not:

      aggregate { aggregate: "t1", pipeline: [ { $match: { username: /^a/ } }, { $group: { _id: "$username", count: { $sum: 1.0 } } } ], cursor: {} } planSummary: IXSCAN { username: 1.0 } keysExamined:2 docsExamined:0 cursorExhausted:1 numYields:0 nreturned:1
      aggregate { aggregate: "t1", pipeline: [ { $match: { username: /^a/ } }, { $group: { _id: 1.0, count: { $sum: 1.0 } } } ], cursor: {} } planSummary: IXSCAN { username: 1.0 } keysExamined:2 docsExamined:1 cursorExhausted:1 numYields:0 nreturned:1
      

              Assignee:
              Anne Lim (Inactive)
              Reporter:
              Asya Kamsky
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

                Created:
                Updated:
                Resolved: