BLUE
Profile banner
RB
Rituraj Borpujari
@riturajborpujari.bsky.social
Coder | Problem Solver | Technology Enthusiast I write at riturajborpujari.com/posts
4 followers23 following28 posts

So the method queried the parents at one go first and then collected all the child IDs into an array and then make batched calls to find those child records. Tried changing the find logic the other way around, search for children by using `parent: <PARENT_ID>` for all parents. That is faster

1

Okay maybe I'm overthinking here, why not just use an aggregation query that hydrates child records by using $lookup? That turned out to be faster as the calls to mongodb were few Also, updated the $projection clause to select only the required fields. Result: 200 hydrated parents in 2s!!!

0
Profile banner
RB
Rituraj Borpujari
@riturajborpujari.bsky.social
Coder | Problem Solver | Technology Enthusiast I write at riturajborpujari.com/posts
4 followers23 following28 posts