[SERVER-22183] Aggregation $match doesn`t increase counter in the $indexStats Created: 14/Jan/16  Updated: 14/Jan/16  Resolved: 14/Jan/16

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: 3.2.0, 3.2.1
Fix Version/s: None

Type: Improvement Priority: Critical - P2
Reporter: marian badinka Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-22048 Index access stats should be recorded... Closed
Participants:

 Description   

Aggregation which uses index (by explain()), doesn`t increase the counter in the statistics visible by $indexStats



 Comments   
Comment by Scott Hernandez (Inactive) [ 14/Jan/16 ]

Yes, this has been scheduled for 3.2.2: SERVER-22048

Comment by marian badinka [ 14/Jan/16 ]

steps to reproduce:
> db.test.insert(a:1,b:2,c:3)
> db.test.insert(a:1,b:2,c:3)
> db.test.insert(a:1,b:2,c:3)

> db.test.createIndex(a:1)

//check stats//
> db.test.aggregate([{$indexStats: {}},{$project:{"_id" : "$name","count" : "$accesses.ops"}}])
"_id" : "a_1", "count" : (0) }
"id" : "_id", "count" :(0) }

//generate aggregation suppose to use index a_1 and increase the counter on $indexStats//
> db.test.aggregate([{$match:{a:1}}]);

{ "_id" : ObjectId("569794a34bf2cadd7dd8ca3d"), "a" : 1, "b" : 2, "c" : 3 } { "_id" : ObjectId("569794a44bf2cadd7dd8ca3e"), "a" : 1, "b" : 2, "c" : 3 } { "_id" : ObjectId("569794a44bf2cadd7dd8ca3f"), "a" : 1, "b" : 2, "c" : 3 }

//check stats again - index "a_1" should have count:1 and not count:0//
> db.test.aggregate([{$indexStats: {}},{$project:{"_id" : "$name","count" : "$accesses.ops"}}])
"_id" : "a_1", "count" : (0) }
"id" : "_id", "count" :(0) }

ciao \ marian

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