-
Notifications
You must be signed in to change notification settings - Fork 96
N+1 Problem? #11
Comments
I had exactly the same question.... I mean, if the N+1 problem is "by design", then it's just unusable, or am I missing something ? |
Batching is the solution but on dotnet is not yet supported it @Bidou44 we depend of open source libraries like that one, or do our own ones for now |
Any more thoughts on this? |
We're solving this by having a top-level resolver that converts the GraphQL query to a Gremlin query so we can fetch the whole dataset in one query to our CosmosDB backend. |
@BenjaBobs, nice, you're using CosmosDb? I'm currently trying graphql-net and GraphQL.Net to Cosmos Db, but still seeing lots of limitations on both. Do you have anything open source you can share? Are you saying you're handling specific cases that involve join-like queries by creating top-level named queries for them? Like "userWithFriends" or something? |
I don't have anything open source, but I can talk a bit about my strategy. Firstly, all of my entities are stored in Cosmos, I don't know how I will handle other data sources yet. On the dotnet side As example, imagine an entity called Car.
The EntityList queries are the interesting ones. For each of these I also generate query arguments based on the entity properties and their types.
The On the Azure side I've experienced that when doing a query with many nestings performance drops, but if I keep my queries to a max depth of 2, I get really snappy responses (ofc keeping in mind that more data = slower queries). |
Awesome, thanks @BenjaBobs, I'm not too familiar with Graph API / Gremlin, I'm leaning towards using the SQL API as it's more familiar to me. I started using GraphQL.Net which is nice because it translates queries into IQueryables for running against the DB, but it doesn't support variables, doesn't seem to work with filtering scalars on properties nested in documents, and isn't .NET Standard supporting. These issues are all starting to add up and make it difficult :P In a few minds now, try and fix GraphQL.Net and make it more CosmosDB compatible, or make my own kind of translator from graphql queries to the CosmosDB SQL-syntax to use in graphql-dotnet resolvers as it seems more established and active. |
If you can wrap your mind around using CosmosDB SQL api, I think that might give you better performance, and it also seem to be a bit ahead of Gremlin api in terms of implemented functionality. Good luck. :) |
https://github.com/dlukez/dataloader-dotnet
Looks like this package is resolving this, but I can not make it work, it fails, do you have another option?
The text was updated successfully, but these errors were encountered: