Repository navigation
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
|
@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