Skip to content

perf(graphql): skip count query for join field using simple pagination #12223

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

Merged
merged 2 commits into from
Apr 29, 2025

Conversation

DanRibbens
Copy link
Contributor

GraphQL requests with join fields result in a lot of extra count rows queries that aren't necessary. This turns off pagination and uses a simple limit and slice instead.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR optimizes GraphQL join field queries by skipping the unnecessary count query and using a simple limit-plus-slice approach for pagination.

  • Updated the find query to request one extra document (limit + 1) to detect if more results exist
  • Disabled built-in pagination and implemented a slicing mechanism to handle the extra document
Comments suppressed due to low confidence (1)

packages/graphql/src/schema/fieldToSchemaMap.ts:411

  • [nitpick] Consider renaming 'shouldSlice' to 'hasExtraDoc' to more clearly indicate that it flags the presence of an extra document used to detect the next page.
let shouldSlice = false

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@DanRibbens DanRibbens merged commit 6b83086 into main Apr 29, 2025
3 checks passed
@DanRibbens DanRibbens deleted the perf/graphql-remove-pagination-joins branch April 29, 2025 02:25
Copy link
Contributor

🚀 This is included in version v3.36.0

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

Successfully merging this pull request may close these issues.

1 participant