Personally, I donβt think itβs a good idea to traverse all the db entries in the code and perform operations many times (e.g. toLowerCase).
A better solution would be to create another table in the SQL database with two columns for the keys and one for the rows.
Now suppose we have table faces, so we create another table * fts_persons *. Each time a new face is added to the face table, a new record is added to the * fts_persons * table. The key in * fts_persons * will be the same as in the face table, and the second column will contain all the materials that can be found for a person, separated by a separator character.
Example:
face table:
1234 | Joe | Sutter | Kingston Road | 23 | Working
Fts_persons table:
1234 | joe + sutter + kingston road + 23 + worker
Now that you are doing a full-text search, you just do the MATCH query for the keys in the * fts_persons * row column. If there are several matches, you will get a list of keys for which you can make another request in the persons table. Or you can combine these two queries into one, which will make things even faster.
Of course, you must synchronize the fts tables with the tables for which they are created, so each time the face table is updated or deleted, you must update or delete the affected column in the * fts_persons * table. For this, it is best to use triggers in an SQL database.
Marek szanyi
source share