Skip to content

Fixed issue 125, added list_slice_length to default resolver #143

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

Conversation

sostholm
Copy link
Contributor

Hello :)

By using the length generated by list_length = iterables.count() in default_resolver and giving it as the argument list_slice_length to connection_from_list_slice, the following code is avoided in connection_from_list_slice (graphql_relay):

if list_slice_length is None:
list_slice_length = len(list_slice)

Looks like this is a very expensive operation for calculating the queryset length.

This reduced the time required to grab the first n objects of a collection of 12000 from +2s to 0.02s.

Passes all tests.

@abawchen
Copy link
Collaborator

@sostholm : Great! Thanks for this PR!

@abawchen abawchen merged commit 96decd6 into graphql-python:master Mar 23, 2020
@sostholm sostholm deleted the fix-125-MongoengineConnectionField-paging-is-SLOW branch March 23, 2020 14:51
arunsureshkumar pushed a commit to arunsureshkumar/graphene-mongo that referenced this pull request Nov 2, 2020
…neConnectionField-paging-is-SLOW

Fixed issue 125, added list_slice_length to default resolver
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants