Make sure you have the correct index as above.
Also, do not delete your database with too many queries. The database is easier to destroy on 100 queries, each of which takes 10 lines, and not 10 queries, each of which takes 10 lines.
So, after the user typed, say, 3 letters, ask for a little more data than you are showing. Let's say you show 10 lines, take 100.
When a user types a different letter, he is likely to use the following 10 values. This way you will send fewer queries to the database.
In the most optimistic case, the user search value will be selected in 1 or 2 queries.
Also, remember the buffer so that you are not forced to resubmit the request when the user deletes the last character.
source share