Skip to content

Use of DataLoader to solve exorbitant query times #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
illeatmyhat opened this issue Jul 29, 2018 · 4 comments
Closed

Use of DataLoader to solve exorbitant query times #45

illeatmyhat opened this issue Jul 29, 2018 · 4 comments
Labels

Comments

@illeatmyhat
Copy link

illeatmyhat commented Jul 29, 2018

There's a dramatic reduction in query performance when using GraphQL with graphene-mongo, as opposed to a regular REST API doing something like list(collection.objects.all()) and sending the entire document set. From 300ms to over 6 seconds to retrieve one field from 100 elements.

I believe that using the DataLoader pattern is the expected solution to the N+1 problem, but actually attempting to use it will cause a runtime error

graphql.error.located_error.GraphQLLocatedError: Data loader batch_load_fn function raised an Exception: AttributeError("type object 'Person' has no attribute 'objects'",)
@abawchen
Copy link
Collaborator

@illeatmyhat 👍
I have time to take care it now :bowtie:
Would you please provide your snippet code? Thanks.

@illeatmyhat
Copy link
Author

Unfortunately I've put GraphQL on the backburner since this issue and don't have the code.

@abawchen
Copy link
Collaborator

@illeatmyhat : It supports relay query with DataLoader by #91, but not sure solves your error or not, and I think it needs to do some change of the backend implementation you work with.

Since you don't have the code that I can't investigate further 😟

@abawchen
Copy link
Collaborator

@illeatmyhat : Close this one since it's stale, and maybe it has been addressed in #115 and #125. I will try to follow up these 2 items.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants