-
Notifications
You must be signed in to change notification settings - Fork 37
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
faster total_site_certificates_as_of_date #473
Conversation
avoid pulling thousands of certificates just for count using .first() to utilize SQL LIMIT 1 : https://github.com/django/django/blob/2a62cdcfec85938f40abb2e9e6a9ff497e02afe8/django/db/models/query.py#L651-L654 Debugging doc: https://appsembler.atlassian.net/wiki/spaces/RT/pages/2680783079/RED-3513+-+Debug+slow+response+times#Figures-slow-query
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @OmarIthawi
@OmarIthawi I'm reviewing this PR. I'm going to do some poking around. I just want to add a note of caution at this point. Sometimes MySQL has degraded performance when using |
@OmarIthawi What do you think of skipping the initial check if there are records. This should work. I ran it in the Django shell for dates that would return both records and return no records
You probably also want to make sure that test coverage covers both cases edit this might not work. I need to look over what's being collected so we're duplicating counts. If the 'num_learners_completed' is just for that given day, we're good. If it is a running total, then my suggestion is not going to work edit Checked the data. It looks cumulative. Sigh. This shows I prematurely optimized. I should have retained the value just for the given day |
Thanks @johnbaldwin. Yes, I think I've had this and sadly it sometimes slows even without |
avoid pulling thousands of coursedailymetric instances just for count
using
queryset.first()
to utilize SQL LIMIT 1 : https://github.com/django/django/blob/2a62cdcfec85938f40abb2e9e6a9ff497e02afe8/django/db/models/query.py#L651-L654Debugging doc: https://appsembler.atlassian.net/wiki/spaces/RT/pages/2680783079/RED-3513+-+Debug+slow+response+times#Figures-slow-query