Skip to content

fix(graphql): Optimize N+1 query for occurrences pEvent and languages#505

Draft
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/graphql-occurrence-n1
Draft

fix(graphql): Optimize N+1 query for occurrences pEvent and languages#505
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/graphql-occurrence-n1

Conversation

@sentry

@sentry sentry Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

This PR resolves an N+1 query issue occurring when fetching PalvelutarjotinEvent data for each Occurrence and languages for each Occurrence within GraphQL queries.

Specifically, OccurrenceNode.get_queryset() in occurrences/schema.py has been updated to include select_related("p_event") and prefetch_related("languages"). This ensures that the related PalvelutarjotinEvent object and languages are fetched efficiently in a single query (or a minimal number of queries for prefetch_related) when occurrences are retrieved, significantly reducing database load for GraphQL requests to the /graphql/ endpoint that include occurrence details.

Fixes KULTUS-API-B

@sonarqubecloud

Copy link
Copy Markdown

@azure-pipelines

Copy link
Copy Markdown

KULTUS-API branch is deployed to platta: https://kultus-pr505.api.dev.hel.ninja 🚀🚀🚀

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.

0 participants