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!