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 the version list screen #5460

Merged
merged 2 commits into from Mar 18, 2019
Merged

Conversation

@davidfischer
Copy link
Contributor

@davidfischer davidfischer commented Mar 14, 2019

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 Mar 14, 2019
stsewd added a commit to stsewd/readthedocs.org that referenced this issue Mar 14, 2019
This also checks for is_superuser first

Kind of related to readthedocs#5460
stsewd
stsewd approved these changes Mar 14, 2019
Copy link
Member

@stsewd stsewd left a comment

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

@agjohnson
Copy link
Contributor

@agjohnson agjohnson commented Mar 15, 2019

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

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

@davidfischer davidfischer commented Mar 16, 2019

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

@ericholscher ericholscher commented Mar 18, 2019

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
1 check passed
@delete-merged-branch delete-merged-branch bot deleted the davidfischer/optimize-versions-page branch Mar 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants