I have a very large collection. It has about 60+ million documents. I am trying to retrieve large subset of documents but the query I have written is taking so long and often giving me timeouts. Here is my query:
{
"type":"xyz",
"$or":[
{
"is_custom":false
},
{
"is_custom":{
"$exists":false
}
}
],
"status":{
"$in":[
"Active",
"Pending"
]
}
}
Projection
_id : 1
id : 1
Limit: 5000
Sort:
_id : 1
I created this index:
{
"type" : 1,
"is_custom" : 1,
"status" : 1,
"id:" : 1,
"_id" : 1
}
MongoDB is not accepting this index. Any idea how to make this query faster? I have to iterate over 3million docs so I am using _id > _id retrieved from previous query approach.