From time to time I see pattern matching queries with conditions that look like this: “where fieldname like ‘%something%’ “. MySQL cannot use indexes for these kinds of queries, which means it has to do a table scan every single time.
(That’s really only half true — there are the FullText indexes. In another blog post I will cover FullText indexes as well.)
I recently was trying to find a solution, and my
friend Charles Nagy reminded me of Trigrams. Let me show you the Trigram of the name
Daniel:
daniel: dan ani nie iel
But how is this useful?
Let me show you an example. You have the following email …
[Read more]