db.deviceLog.aggregate([
{
$match:
{
"createTime":{ $gte: ISODate("2024-01-01T00:00:00Z"), $lte: ISODate("2024-02-10T00:00:00Z") }
}
},
{
$lookup: {
from: "device",
localField: "deviceId",
foreignField: "deviceId",
as: "info"
}
},
{
$match: {"info.userId": 1}
},
{
$limit: 10
}
}
此时如果过滤{ $match: {"info.userId": 1} }的时候,如果device没有任何一条匹配,或者匹配条目靠后,查询数据甚至会达到几分钟, 请问我用该怎么解决这个问题?
相似问题