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

Optimize inefficient database query in the deviation list view #1304

Merged
merged 1 commit into from
Nov 13, 2023

Conversation

ihalaij1
Copy link
Contributor

@ihalaij1 ihalaij1 commented Nov 7, 2023

Description

What?

The course module name is no longer queried separately for each deviation. This reduces the number of performed queries significantly. Additionally, some large unnecessary attributes are no longer loaded.

Why?

The deviations list page loaded extremely slowly before. This should help with the problem.

Fixes #1302

@jsorva
Copy link

jsorva commented Nov 8, 2023

Sounds very promising!

Copy link
Contributor

@PasiSa PasiSa left a comment

Choose a reason for hiding this comment

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

Looks good to me. Small proposal related to the placement of defer call, though.

)
# parent is prefetched because there may be multiple ancestors, and
# they are needed for building the deviation's URL.
.defer(
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor nit: I think the defer call should be before the comment above, that refers to prefetch_related.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree.

Copy link
Contributor

@markkuriekkinen markkuriekkinen left a comment

Choose a reason for hiding this comment

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

Looks good! You can merge this after you have moved the comment as Pasi suggested.

)
# parent is prefetched because there may be multiple ancestors, and
# they are needed for building the deviation's URL.
.defer(
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree.

The course module name is no longer queried separately for
each deviation. This reduces the number of performed
queries significantly. Additionally, some large unnecessary
attributes are no longer loaded.

Fixes apluslms#1302
@ihalaij1 ihalaij1 merged commit a3ac989 into apluslms:master Nov 13, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Optimize the very inefficient database queries in the deviation list view
4 participants