I’ve been working on an iOS app that links to my MongoDB Realm using Apollo and the GraphQL integration. I noticed that I was getting really slow API response times with GraphQL, and figured that it was because I am currently in Australia (quite far from the server), but after some additional playing around with my queries, I realised something else was making the requests slow!
Basically, my request is using the _id_in query for an array of roughly 40 ids, and returns a response with some properties, as well as 3 related documents stored in other collections. When I include these 3 relationships in the query, the query takes ~10 seconds. When I don’t include these relationships, the query takes <1 second.
It seems like when I include the relationships in the query, the complexity jumps to O(N).
All the related document collections are indexed by _id (as I figure the GraphQL integration would use), but is there another index that I should be making to speed up this query, or is this just a limitation of the Realm GraphQL integration? It’s really slowing down the performance of my app pretty much everywhere!
Thanks so much for your help!