const d = new Date().getTime()+(1200*1000);
const query = {
userId: ObjectId(userId),
timestamp: {
$lte: d
},
$or: [
// {
// status: "Active"
// },
// {
// status: "Removed"
// }
]
}
Db.orders.findOne(query, () => {
console.log(`[1]:`, 1)
return resolve();
})
If I uncomment the statuses in the $or it will burst the cpu from 0.3% to 300%.
This is the index that was set on this collection: userId: 1, timestamp: 1, status: 1
If I try to find without the $or - like that: {status: "Active"}
It won't burst and won't cause any issue.
Why does it happening?