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

Speed up /admin statistics page "Requests & Events" #333

Merged
merged 1 commit into from
Jun 5, 2020
Merged

Speed up /admin statistics page "Requests & Events" #333

merged 1 commit into from
Jun 5, 2020

Conversation

mherrmann
Copy link
Collaborator

When there are millions of requests in the database, this page took tens of seconds to load. In extreme situations, it could even DoS the database, and thus kill the server.

The reason was an unnecessary .distinct() call on the QuerySet that contains the AppRequests. The call was unnecessary because Django automatically fetches the id for each AppRequest. Every row thus had a unique id, and was thus necessarily distinct from all the others. This PR removes the .distinct() call, which leads to a very significant performance improvement.

When there are millions of requests in the database, this page took
tens of seconds to load. The reason was an unnecessary .distinct(...)
call on a QuerySet. This commit removes this call.
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.004%) to 82.139% when pulling ab22d5b on mherrmann:faster-request-stats into b69ecab on Crystalnix:master.

@mherrmann
Copy link
Collaborator Author

Would also appreciate at least a cursory comment on this :-)

@mherrmann mherrmann merged commit 0d355b9 into omaha-consulting:master Jun 5, 2020
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.

None yet

2 participants