与填充一起使用时猫鼬查询性能低下
mongoose query low performance when using with populate
我需要有关此查询的帮助。
我正在使用 4 个集合 populated.But 在 AppVisitor 中查询 8000 个文档,但没有 return 任何结果。意味着它卡住了,一段时间后 nodejs 服务器 return 执行此查询的路由出现 404 错误。
let Keys = yield AppVisitor.find(condition).sort({ createdAt: -1 })
.populate({ path: 'userDeatils' })
.populate({ path: 'details' })
.populate({
path: 'skills',
match: {
$and: [{ value: { $ne: '' } }, { value: { $ne: null } }, { value: { $not: /({R[\d]+})/g } }]
}
})
.populate({ path: 'courses' });
我想尝试重组您的集合可能会有所帮助,并减少使用填充函数,因为它相当繁重operation.Make请确保您在使用填充时知道自己在做什么。
我需要有关此查询的帮助。 我正在使用 4 个集合 populated.But 在 AppVisitor 中查询 8000 个文档,但没有 return 任何结果。意味着它卡住了,一段时间后 nodejs 服务器 return 执行此查询的路由出现 404 错误。
let Keys = yield AppVisitor.find(condition).sort({ createdAt: -1 })
.populate({ path: 'userDeatils' })
.populate({ path: 'details' })
.populate({
path: 'skills',
match: {
$and: [{ value: { $ne: '' } }, { value: { $ne: null } }, { value: { $not: /({R[\d]+})/g } }]
}
})
.populate({ path: 'courses' });
我想尝试重组您的集合可能会有所帮助,并减少使用填充函数,因为它相当繁重operation.Make请确保您在使用填充时知道自己在做什么。