I have table that contains five million addresses as strings.
There is a user interface that allows you to search by address and it is implemented in the simplest possible way - using the LIKE
syntax with wildcards at the both ends of the searched string.
However this approach is really slow (especially when search result has to be sorted by some criteria).
I thought of using fulltext search as it would be much faster but it limits users and I dont want it since most search queries contain just part of word.
Addresses also can be abbreviated.
What can I do? How could I implement the address search to be more efficient but without sacrificing much of the user experience.
Edit
Ive just read that I can actually use a wildcard at the end of the string when performing match against
fulltext search.
So if i store the reversed address maybe I can do prefix wildcard fulltext search.
But will it be faster and how much? Are there some benchmarks? I couldn find one.