Skip to content

Optimize the version list screen #5460

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

Merged
merged 2 commits into from
Mar 18, 2019

Conversation

davidfischer
Copy link
Contributor

This page was timing out due to permission checks {% if request.user|is_admin:project %} performed in a loop of all versions for a project with ~1k versions. That permission check was generating a database query per version (2 actually). This changes the view such that users for a project are cached and the permission check won't hit the database again.

Fixes #5458

@davidfischer davidfischer requested a review from a team March 14, 2019 21:54
stsewd added a commit to stsewd/readthedocs.org that referenced this pull request Mar 14, 2019
This also checks for is_superuser first

Kind of related to readthedocs#5460
Copy link
Member

@stsewd stsewd left a comment

Choose a reason for hiding this comment

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

I don't see +1K of queries with this change :)

@agjohnson
Copy link
Contributor

Is it worth adding a test to track the number of queries for this? We talked about doing similar eventually, so if we don't have an existing test like this, then perhaps we punt on doing the tests here. It would be a helpful thing to track though.

Change looks good otherwise. If we don't want to track adding the tests now, perhaps we should have issue tracking some of the places we should be tracking # of queries.

Copy link
Contributor

@agjohnson agjohnson left a comment

Choose a reason for hiding this comment

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

Change LGTM. Noted potential for tests, but I'll leave the decision whether to tackle now or later up to @davidfischer

@davidfischer
Copy link
Contributor Author

Let me give testing this a try with assertNumQueries. Testing the queries of a full view is trickier than say a method because random things like changes to session handling or unrelated view changes can result in an extra query or two.

@ericholscher
Copy link
Member

Merging this, can futz with a test later. Could perhaps asset "Number of queries less than X" or similar?

@ericholscher ericholscher merged commit 96d4e31 into master Mar 18, 2019
@delete-merged-branch delete-merged-branch bot deleted the davidfischer/optimize-versions-page branch March 18, 2019 15:39
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.

4 participants