Details
-
Bug
-
Status: Closed
-
Major - P3
-
Resolution: Duplicate
-
None
-
None
-
None
-
None
-
ALL
Description
Hello,
I have a large sharded collection with similar documents. A part of them have a field called "tag", which is always a string. I've indexed the field using partialFilterExpression:
{"v" : 2, |
"key" : { "tag" : 1 }, |
"name" : "tag", |
"ns" : "database.collection", |
"partialFilterExpression" : { |
"tag" : { "$exists" : true } } |
}
|
However, when i run database.collection.count_documents({"tag": "value"}), the result takes a long time to complete. Running current_op shows me the query running:
"secs_running" : NumberLong(616), |
"microsecs_running" : NumberLong(616856589), |
"op" : "getmore", |
"ns" : "database.collection", |
"command" : { |
"getMore" : NumberLong("4801338963376724146"), |
"collection" : "collection", |
"planSummary" : "IXSCAN { tag: 1 }", |
"cursor" : { |
"cursorId" : NumberLong("4801338963376724146"), |
"createdDate" : ISODate("2019-11-26T13:23:57.281Z"), |
"lastAccessDate" : ISODate("2019-11-26T13:23:57.282Z"), |
"nDocsReturned" : NumberLong(0), |
"nBatchesReturned" : NumberLong(0), |
"noCursorTimeout" : false, |
"tailable" : false, |
"awaitData" : false, |
"originatingCommand" : { |
"$truncated" : "{ $truncated: \"{ aggregate: \"collection\", pipeline: [ { $match: { tag: \"value\" } }, { $group: { _id: { $const: 1 }, n: { $sum: { $const: 1 } } } } ], fro...\" }" |
},
|
So i'm running an aggregate, which i know can be slow. I remember running these kind of queries very fast, when the field was indexed. Is this because the index is a partialFilterExpression? If so, it looks like a bug, because i think it should be able to use the information from that index in order to complete a simple count operation.
I'm running mongod 4.2.1, and the count was issued with pymongo 3.9.0.
Attachments
Issue Links
- duplicates
-
SERVER-28889 Partial index shouldn't do fetch on conditions that are true by the definition of the index
-
- Open
-