Answer the question
In order to leave comments, you need to log in
How to optimize the search for a phone number (part of a string)?
Has anyone run into the slow LIKE "%str%" gag, I'm sure. Now there are about 300k records in the table and there will only be more. According to this table, you need to search for lines by phone number: completely, beginning, end.
Examples:
Answer the question
In order to leave comments, you need to log in
1. Is there an index?
2. Open EXPLAIN/DESCRIBE and look for the problem.
3. Try throwing a fultext index and searching with MATCH
4. Why is there a PHP tag here?
First, use the index. It will work on full match or search at the beginning.
Second, you can opt out of like %phone% if you have different searches. It looks for any occurrence. It is better to replace separately with:
`phone` like "000" complete.
`phone` like "000%" at the beginning .
`phone` like "%000" at the end - does a fullscan, not optimized
by
indexes application level search by full equality on the desired column
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question