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

An API that fetches a tree of Parent Child objects from a single mongodb collection needs improvement. The response times are really bad, fetching 150 parent with around 20 hydrated child records takes around a min!!! Need to dig in!

1

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
Profile banner
RB
Rituraj Borpujari
@riturajborpujari.bsky.social
Coder | Problem Solver | Technology Enthusiast I write at riturajborpujari.com/posts
4 followers23 following28 posts