Skip to content
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

Remove extra count query for hasNextPage when paginating #3373

Merged
merged 1 commit into from
Mar 4, 2021

Conversation

vahe
Copy link
Contributor

@vahe vahe commented Mar 4, 2021

This PR adds an optimization for an edge case (probably very common code path though) in pagination when querying for hasNextPage.

Currently, we get the value of hasNextPage by comparing the result of count query with limit first + 1 with first (query param) + 1.

We can eliminate the count query in cases where nodes are already fetched and there's less than specified in first param.

@vahe vahe changed the title Reduce extra query for hasNextPage when paginating Reduce extra count query for hasNextPage when paginating Mar 4, 2021
@vahe vahe changed the title Reduce extra count query for hasNextPage when paginating Remove extra count query for hasNextPage when paginating Mar 4, 2021
@vahe vahe force-pushed the optimize-hasNextPage-edge-case branch from 50e7680 to e9841a8 Compare March 4, 2021 02:22
@vahe vahe force-pushed the optimize-hasNextPage-edge-case branch from e9841a8 to eb1f6ec Compare March 4, 2021 02:23
@rmosolgo rmosolgo added this to the 1.12.6 milestone Mar 4, 2021
@rmosolgo
Copy link
Owner

rmosolgo commented Mar 4, 2021

This is great -- thanks so much for sharing (and testing) this fix!

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