Skip to content
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

Prefetch related models in FPR views #1985

Merged
merged 5 commits into from
Aug 29, 2024
Merged

Prefetch related models in FPR views #1985

merged 5 commits into from
Aug 29, 2024

Conversation

replaceafill
Copy link
Member

Many views in the FPR have the N+1 Queries problem where multiple/separate queries are created to select single related rows in the database. For example, to create an FPR rule every single Format is retrieved separately, and after its related FormatGroup.

This PR adds prefetch_related calls to specific QuerySets in views and forms to retrieve the related models beforehand.

The values of the `The related output format` field are string
representations of the Format models. The __str__ method of the Format
model prints its related FormatGroup.

This prefetches the FormatGroup models in advance in the queryset of
the field so it doesn't require separate queries for each Format.
@replaceafill replaceafill added AMAUAT Issues relating to the improvement of the AM Automated Acceptance tests and removed AMAUAT Issues relating to the improvement of the AM Automated Acceptance tests labels Aug 27, 2024
Copy link
Contributor

@Dhwaniartefact Dhwaniartefact left a comment

Choose a reason for hiding this comment

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

LGTM!

@replaceafill replaceafill merged commit 48d3c11 into qa/1.x Aug 29, 2024
45 checks passed
@replaceafill replaceafill deleted the dev/fpr-queries branch August 29, 2024 20:16
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