Skip to content

More performance optimizations#756

Open
otargowski wants to merge 14 commits into
sio2project:masterfrom
otargowski:perf-opts-PR-2
Open

More performance optimizations#756
otargowski wants to merge 14 commits into
sio2project:masterfrom
otargowski:perf-opts-PR-2

Conversation

@otargowski

@otargowski otargowski commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

A continuation of #690. A few last views were improved to use O(1) queries, most notably the submit view (I found a not too invasive way with prefetch_related) and contest rules view.

Other than that, many prefetch_related calls were replaced with new annotate_known_related[_many] utilities, which make use of already known related objects, e.g. for Submission.objects.filter(problem_instance__in=problem_instances), we can "annotate" problem_instances. This has the huge benefit of not needing to prefetch transitively related objects all the time, like round, problem and contest in the example, which makes the code cleaner and less prone to someone forgetting to prefetch some relation in the future.

eval_contest_submissions_qs_with_common_related was also introduced, which annotates already fetched problem instances with all their related objects and also prefetches stuff for oioioi.scoresreveal if it is enabled (now this ugly if is in one place instead of a few).

There are also a few other small optimizations and cleanups.

@sonarqubecloud

sonarqubecloud Bot commented Jun 3, 2026

Copy link
Copy Markdown

@otargowski otargowski marked this pull request as ready for review June 3, 2026 10:45
@otargowski otargowski requested a review from MasloMaslane as a code owner June 3, 2026 10:45
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.

1 participant