Avoid the next page check query in GraphQL
What does this MR do and why?
This MR removes the extra next page check query from GraphQL. The old implementation runs an additional DB query (OFFSET $PAGE_SIZE + 1 LIMIT 1
) to check if there is a next page. In some cases, the check query is as expensive as the actual query that loads the records.
How
Request LIMIT + 1
records but only return LIMIT
records. Use the last (not used) record to determine if there is a next page.
Example:
With this MR the second query will not happen.
How to set up and validate locally
- Enable the invite modal
Feature.enable(:graphql_keyset_pagination_without_next_page_query)
- In a group, create a new label and go to a project (copy the project id).
- Generate some issues
15.times { FactoryBot.create(:labeled_issue, project: Project.find("YOUR_PROJECT_ID"), labels: [Label.find_by_name("YOUR_LABEL_NAME")] ) }
- Got to group / issues / boards
- Create a new board and add a list with the created label
- Inspect the executed SQL queries. You should see only one query for the
issues
table.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Adam Hegyi