prefetch participant and voter counts in contributor index - #2714
Conversation
4687711 to
01d64f2
Compare
richardebeling
left a comment
There was a problem hiding this comment.
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).
01d64f2 to
2e3855f
Compare
|
finally found some time to revisit this.
No, because we do not have < N queries yet. With 100 evaluations, contributions, we have 540 queries. Without this PR, we have ~200 more. For a test, I can cut down the number if objects (say 10 each) and assert that we are not constant (currently 90 queries, so assert we make 80-100 queries). For reference, the constant PoC at #2715 has 43 queries. |
richardebeling
left a comment
There was a problem hiding this comment.
Nice, thanks. The fixed contributor page (via #2715) is going to be epic.
| cls.responsible = result["responsible"] | ||
| cls.test_users = [result["editor"], cls.responsible] | ||
|
|
||
| def test_num_queries_is_not_constant(self): |
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).