[SERVER-22048] Index access stats should be recorded for $match & mapReduce Created: 04/Jan/16  Updated: 18/Nov/16  Resolved: 13/Jan/16

Status: Closed
Project: Core Server
Component/s: Aggregation Framework, Querying
Affects Version/s: 3.2.0
Fix Version/s: 3.2.3, 3.3.1

Type: Bug Priority: Major - P3
Reporter: James Wahlin Assignee: James Wahlin
Resolution: Done Votes: 0
Labels: code-and-test
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-22183 Aggregation $match doesn`t increase c... Closed
Related
related to DOCS-6973 Add note about $indexStats limitation... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Completed:
Steps To Reproduce:

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);
    }
}

Sprint: QuInt E (01/11/16), Query F (02/01/16)
Participants:

 Description   

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.



 Comments   
Comment by Githook User [ 13/Jan/16 ]

Author:

{u'username': u'jameswahlin', u'name': u'James Wahlin', u'email': u'james.wahlin@10gen.com'}

Message: SERVER-22048 Add index stats test covering multiple potential plan match

(cherry picked from commit c8bc89143725e9c88bb80ca84a261024e170dc50)
Branch: v3.2
https://github.com/mongodb/mongo/commit/ee3f14ec31f9a0f0bed04adfc08393f9a23f97f6

Comment by Githook User [ 13/Jan/16 ]

Author:

{u'username': u'jameswahlin', u'name': u'James Wahlin', u'email': u'james.wahlin@10gen.com'}

Message: SERVER-22048 Record index access stats for aggregation and mapReduce

(cherry picked from commit 176fad1a68fd9d0750a3aa4b33c2eb20be7d39ec)
Branch: v3.2
https://github.com/mongodb/mongo/commit/fb79259aa514aab9682328fc430e1a833d808baf

Comment by Githook User [ 12/Jan/16 ]

Author:

{u'username': u'jameswahlin', u'name': u'James Wahlin', u'email': u'james.wahlin@10gen.com'}

Message: SERVER-22048 Add index stats test covering multiple potential plan match
Branch: master
https://github.com/mongodb/mongo/commit/c8bc89143725e9c88bb80ca84a261024e170dc50

Comment by Githook User [ 08/Jan/16 ]

Author:

{u'username': u'jameswahlin', u'name': u'James Wahlin', u'email': u'james.wahlin@10gen.com'}

Message: SERVER-22048 Record index access stats for aggregation and mapReduce
Branch: master
https://github.com/mongodb/mongo/commit/176fad1a68fd9d0750a3aa4b33c2eb20be7d39ec

Generated at Thu Feb 08 03:59:14 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.