Skip to content

prefetch participant and voter counts in contributor index#2714

Open
Kakadus wants to merge 1 commit intoe-valuation:mainfrom
Kakadus:prefetch-contributor-index
Open

prefetch participant and voter counts in contributor index#2714
Kakadus wants to merge 1 commit intoe-valuation:mainfrom
Kakadus:prefetch-contributor-index

Conversation

@Kakadus
Copy link
Copy Markdown
Collaborator

@Kakadus Kakadus commented Apr 29, 2026

relates to #1229

Directly reduces n database hits.
When testing with 200 evaluations 10 times, the accumulated test-runtime was reduced from 50s to 44s on my laptop. Even with 10 evaluations, I see a speedup (4.820s -> 3.689s).

@Kakadus Kakadus force-pushed the prefetch-contributor-index branch from 4687711 to 01d64f2 Compare April 29, 2026 16:30
Copy link
Copy Markdown
Member

@richardebeling richardebeling left a comment

Choose a reason for hiding this comment

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

Lgtm. Can you add a test that asserts that we have < N queries? (I would assume that, for each relation we currently prefetch_related, the test fails if we remove it).

Comment thread evap/contributor/views.py
Comment on lines +82 to 89
).prefetch_related(
"course",
"course__evaluations",
"course__programs",
"course__type",
"course__semester",
"course__responsibles",
)
Copy link
Copy Markdown
Member

@richardebeling richardebeling Apr 29, 2026

Choose a reason for hiding this comment

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

Some of these could be select_relateds (course, course__type, course__semester). You could check whether it improves anything, if yes, we can use that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants