Stop searching the to field

We were doing this temporarily while the `normalised_to` field was not
populated for letters. Once we have a week of data in the
`normalised_to` field we can stop looking in the `to` field. This should
improve performance because:
- it’s one `WHERE` clause not two
- we had to do `ilike` on the `to` field, because we don’t lowercase its
  contents – even if the two where clauses are somehow paralleized it’s
  is slower than a `like` comparison, which is case-sensitive

Depends on:
- [ ] Tuesday 5 May (7 full days after deploying https://github.com/alphagov/notifications-api/pull/2814)
This commit is contained in:
Chris Hill-Scott
2020-04-30 10:51:30 +01:00
parent 26793899d4
commit 1e20cb6be9
2 changed files with 4 additions and 6 deletions

View File

@@ -622,7 +622,6 @@ def dao_get_notifications_by_recipient_or_reference(service_id, search_term, not
filters = [
Notification.service_id == service_id,
or_(
Notification.to.ilike("%{}%".format(search_term)),
Notification.normalised_to.like("%{}%".format(normalised)),
Notification.client_reference.ilike("%{}%".format(search_term)),
),