减少聚合查询时间
我是 mongodb 的初学者。我正在研究两个集合预订和预订日志。我有大约 7000 个预订和 14000 个 booking_logs。
我想使用他们的日志进行预订,其中 booking_logs 存在于预订中。我使用了以下查询。
db.bookings.aggregate([
{$lookup:{
"from":"booking_logs",
"localField":"_id",
"foreignField":"booking_id",
"as":"booking_time_logs"
}},
{"$match":{"booking_time_logs":{"$not":{"$size":0}}}}
])
但是,查询执行时间太长。有什么办法可以减少时间吗?请回答。谢谢你!
I am a beginner in mongodb. I am working on two collections bookings and booking_logs. I have around 7k bookings and 14k booking_logs.
I want to get booking with their logs for which booking_logs exist with bookings. I have used the following query.
db.bookings.aggregate([
{$lookup:{
"from":"booking_logs",
"localField":"_id",
"foreignField":"booking_id",
"as":"booking_time_logs"
}},
{"$match":{"booking_time_logs":{"$not":{"$size":0}}}}
])
But, the query is taking too much time to execute. Is there any way to reduce the time? Please answer. Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论