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

Index access stats should be recorded for $match & mapReduce

    • Fully Compatible
    • ALL
    • Hide

      Reproduction case for aggregation:

      db.test.drop();
      db.test.save({a: 1});
      db.test.ensureIndex({a: 1});
      db.test.aggregate([{$match: {a: 1}}]);
      var statsArr = db.test.aggregate([{"$indexStats": {}}]).toArray();
      for (var idx in statsArr) {
          var doc = statsArr[idx];
          if (doc.name === "a_1") {
              assert(doc.accesses.ops == 1);
          }
      }
      
      Show
      Reproduction case for aggregation: db.test.drop(); db.test.save({a: 1}); db.test.ensureIndex({a: 1}); db.test.aggregate([{$match: {a: 1}}]); var statsArr = db.test.aggregate([{ "$indexStats" : {}}]).toArray(); for ( var idx in statsArr) { var doc = statsArr[idx]; if (doc.name === "a_1" ) { assert (doc.accesses.ops == 1); } }
    • QuInt E (01/11/16), Query F (02/01/16)

      Index access stats, retrievable via the $indexStats aggregation source, track the number of times a given index was used to satisfy a user operation.

      $match as a document source in aggregation can make use of indexes to retrieve documents but is currently not recording usage statistics. Support should be added for $match as exclusion could lead to the wrong conclusion as to whether an index is being used.

      Also missing is a hook to record index access when a mapReduce uses an index to satisfy a "query" argument. This issue will add support for both aggregation and mapReduce.

            Assignee:
            james.wahlin@mongodb.com James Wahlin
            Reporter:
            james.wahlin@mongodb.com James Wahlin
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: