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

GPS : Amélioration des performances de la recherche de bénéficiaires #4475

Merged
merged 1 commit into from
Jul 30, 2024

Conversation

francoisfreitag
Copy link
Contributor

@francoisfreitag francoisfreitag commented Jul 29, 2024

🤔 Pourquoi ?

La recherche de bénéficiaire est une nouvelle entrée dans les vues avec le plus haut User Misery sur Sentry (2ème pire vue du système) avec un P50 à plus de 4 secondes, ce qui affecte la base de données et l’expérience sur le site.

Performances

En utilisant le panneau SQL de DjDT, avec la requête :

curl 'http://127.0.0.1:8000/autocomplete/gps_users?term=dupont&_type=query&q=dupont' 'Cookie: sessionid=SESSIONID'

master: 454 ms
commit: 24 ms

cf https://itou-inclusion.slack.com/archives/C067CP07KJR/p1721834260473969

Instead of generating a new column and searching it with `LIKE %term%`
(icontains), search a user whose first name or last name is `LIKE term%`
(startswith).

Also, use a simpler join to exclude beneficiaries for which the user is
an active member of their follow up group.

Performances
============
Measuring using the SQL panel of DjDT, with the request:
```bash
curl 'http://127.0.0.1:8000/autocomplete/gps_users?term=dupont&_type=query&q=dupont' 'Cookie: sessionid=SESSIONID'
```

master: 454 ms
commit: 24 ms
Copy link
Contributor

@xavfernandez xavfernandez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 la suppression du distinct pour passer au Exists.
A voir si la modif sur la clause de recherche est également acceptable (mais je me demande si l'Exists n'est pas suffisant ?)

search_terms = search_string.split(" ")
name_q = []
for term in search_terms:
name_q.append(Q(first_name__unaccent__istartswith=term))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On passe de icontains à istartswith... Ça n'est pas la même recherche.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je n’ai pas mentionné https://itou-inclusion.slack.com/archives/C067CP07KJR/p1721834260473969 dans la description. On a discuté de ce changement avec Louis-Jean avant que je ne le réalise.
Désolé pour la confusion.

Copy link
Collaborator

@celine-m-s celine-m-s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merci !! 🎉
Effectivement, la recherche n'est pas la même avec les istartwith.

@francoisfreitag francoisfreitag added this pull request to the merge queue Jul 30, 2024
Merged via the queue into master with commit 2ebf857 Jul 30, 2024
11 checks passed
@francoisfreitag francoisfreitag deleted the ff/gps-2 branch July 30, 2024 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants