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

Count plans sometimes don't need a FETCH

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

      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 Anne Lim
            Reporter:
            asya.kamsky@mongodb.com Asya Kamsky
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: