我有一个跟随这个"架构的集合" :
-bash: ${...}: bad substitution
并且索引定义如下:
{
_id: ObjectId,
order: Number,
fieldA: ObjectId,
fieldB: Array[ObjectId]
}
运行像这样的查询查询时:
{
fieldA: 1,
fieldB: 1,
order: 1
}
将{
$and: [
{fieldA: {$in: [{"$oid":"592edae196232608d00f78f5"},{"$oid":"592edadc96232608d00f5614"}]}},
{fieldB: {$in:[{"$oid":"592edace96232608d00ef77f"},{"$oid":"592edacd96232608d00ef34b"}]}}
]
}
定义为
sort
查询运行正常,索引涵盖查询,解释计划显示:
问题:如果我使用巨大 {
order: 1
}
查询fieldA
和/或fieldB
(我试图制作类似连接的内容) ,然后索引行为不一样,查询未涵盖,排序在内存中 ,解释计划显示我:
更糟糕的是,如果我从Mongoose运行此查询,则排序操作将耗尽内存:/