Skip to content

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

kendelljoseph pushed a commit that referenced this pull request May 15, 2025
#12223)

GraphQL requests with join fields result in a lot of extra count rows
queries that aren't necessary. This turns off pagination and uses
limit+1 and slice instead.
kendelljoseph pushed a commit that referenced this pull request May 19, 2025
#12223)

GraphQL requests with join fields result in a lot of extra count rows
queries that aren't necessary. This turns off pagination and uses
limit+1 and slice instead.
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