Assume I have a user table in PostgreSQL with columns
first_name (PK)
last_name (PK)
email
There are now millions of users in it. One user has the record
(John, Smith, [email protected])
Now I search for him and enter erroneously Johny Smit.
How can I still find the record and this really quick? Is that possible with sqlalchemy as well?
You can use trigram-based indexing and search included in the
pg_trgmextension: demoJohn Smithunder a pile of 100k randomuuids.last_namehas some priority over the match onfirst_name, especially since last names aren't altered as often (diminutives, abbreviation, nicknames, second names, etc.).