I have one query on database My collection have 210 million docs And there is one query I am execute like {a : id, $or : [{b:id,c:stringId},{b: $in_large_array,c:$in_large_arrray,d : $in_large_array}]} Above is my query and when I apply sort it doesnt wor
where is your query?
I have a problem too. My car does not work.
Seriously, do you think anyone can help me fix my car when the only piece of information I give is My car does not work.
Seriously, we need to know what you mean by it does not work.
Do you have error messages?
If no error messages, do you mean the sort order is wrong? If the sort is wrong it would be good to see what sort you are applying. It would also be good to see sample documents that are in the wrong order.
db.form_response.aggregate([
{
$match: {
PartnerId: “585938e3d4e9dac9bb2b09c6”,
$or: [
{
BusinessID: 287892,
FormID: “64d9f5732061202e2576df19”
},
{
mlGroupIds: { $in: [NumberLong(3071),
NumberLong(3095),
NumberLong(3096) ]},
BusinessID: { $in: [NumberLong(285325),NumberLong(287890),NumberLong(287891)]},
FormID: { $in: [“64d9f5732061202e2576df19”,“64d9f8b8ec1f6cc819583949”,“64d9fbc5ec1f6cc81958398a”]}
}
]
IsDeleted: false
},
},
{
$sort : {RespDate : -1}
}
],{allowDiskUse : true,hint : “PartnerId_1_IsDeleted_1_RespDate-1_BusinessID_1_FormID_1_mlGroupIds_1”})
{a : id, $or : [{b:id,c:stringId},{b: $in_large_array,c:$in_large_arrray,d : $in_large_array}]}
I mean could you please suggest me a proper index
After filter my result set is around 766K docs and I am use m50 server
Using the principles outlines by the ESR rules I would start to experiment an index on
PartnerId because of the exact match
RespDate because you sort
I would handle the IsDeleted by using a partial index.
Please follow up on your thread.
Thanks