Improve query performance

Adding a filter to `app.dao.notifications_dao.is_delivery_slow_for_providers` query to improve the performance. By added Notifications.notification_type = 'sms' to the query it will improve the performance some analyse shows 500ms improvement, which is a good thing especially when the query is run once a minute.
This commit is contained in:
Rebecca Law
2021-11-30 16:42:32 +00:00
parent ad313065bf
commit 101498ec84

View File

@@ -558,6 +558,7 @@ def is_delivery_slow_for_providers(
ProviderDetails
).outerjoin(
Notification, and_(
Notification.notification_type == SMS_TYPE,
Notification.sent_by == ProviderDetails.identifier,
Notification.created_at >= created_at,
Notification.sent_at.isnot(None),