Repository navigation
⚡️(backend) search users through the trigram indexes - #2906
Conversation
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughBackend user searches now use unaccented trigram matching to find email and full-name candidates. Email searches also apply a Levenshtein distance limit. Other searches place shared-document users before same-domain matches and cap the combined results. The search sets a transaction-local trigram threshold. Tests check result ordering, index use, and threshold reset. Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~25 minutes Suggested reviewers: Merge Risk: ⚪ Minimal · up to
|
The user search filtered on a similarity score computed on the raw email and full_name columns. The trigram indexes are built on f_unaccent(email) and f_unaccent(full_name) and only serve the % operator, so each search scanned the whole user table, and all the matches were then filtered and sorted in Python. The search now uses the % operator on the indexed expressions, with a similarity threshold scoped to the transaction. It filters the shared and same-domain users in SQL, and fetches no more users than the response limit.
b61ab0a to
47609af
Compare
Purpose
The user search filtered on a similarity score computed on the raw email and full_name columns. The trigram indexes are built on f_unaccent(email) and f_unaccent(full_name) and only serve the % operator, so each search scanned the whole user table, and all the matches were then filtered and sorted in Python.
The search now uses the % operator on the indexed expressions, with a similarity threshold scoped to the transaction. It filters the shared and same-domain users in SQL, and fetches no more users than the response limit.
Proposal