Skip to content

CV2-6730: N+1 Query (task_response) - #2442

Merged
melsawy merged 1 commit into
developfrom
CV2-6730-n-1-query-task-response
Jul 13, 2026
Merged

CV2-6730: N+1 Query (task_response)#2442
melsawy merged 1 commit into
developfrom
CV2-6730-n-1-query-task-response

Conversation

@melsawy

@melsawy melsawy commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Description

Both GraphQL fields first_response and first_response_value executed a separate database query for each Task to return the response which cause N+1 query pattern.

Added a loader (FirstResponseLoader) that batches all requested task IDs into a single query and caches the results for the duration of the GraphQL request. Both fields use the same loader, allowing them to reuse the fetched Annotation without issuing additional queries.

References: CV2-6730

How to test?

Re-run unit tests

Checklist

  • I have performed a self-review of my code and ensured that it is safe and runnable, that code coverage has not decreased, and that there are no new Code Climate issues. I have also followed Meedan's internal coding guidelines.

@melsawy
melsawy requested a review from caiosba July 13, 2026 10:42
@melsawy
melsawy merged commit 0b1474c into develop Jul 13, 2026
12 of 13 checks passed
@melsawy
melsawy deleted the CV2-6730-n-1-query-task-response branch July 13, 2026 15:47
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