I have a collection with over 1 billion documents. Some of them have the field extra.id
but a majority don't. I have an index set as described below. When I run a simple query to get the count of documents with extra.id
set, the query takes ages to complete. Actually, I have never waited long enough for it to complete. I'd expect <1s response and what I get instead is >15min (before I kill it). I am running MongoDB 3.4.7 on Ubuntu while connecting from a Windows client.
What is going on? I thought partial filter expression was going to help here because the query should simply return the count of indexed documents.
Query
db.handles.find({"extra.id":{$exists:true}}).count()
Index
{
"v" : 1,
"name" : "extra.id_1",
"ns" : "pull.handles",
"background" : true,
"partialFilterExpression" : {
"extra.id" : {
"$exists" : true
}
}
}