Not recommended to use fuzzy queries prefix%
For example LIKE "% name" or LIKE "% name%", such a query can lead to failure while the index for full table scan. But you can use LIKE "name%".
How that query% name%?
Although the index is added to the secret field, but did not explain the use of the results:
So how to solve this problem, the answer is: Use full-text indexing.
In our queries often use the select id, fnum, fdst from dynamic_201606 where user_name like '% zhangsan%';. Such a statement, the general index is unable to meet the needs of the inquiry. Fortunately, in MySQL, full-text indexing to help us.
Create a full-text index of SQL syntax is:
ALTER TABLE `dynamic_201606` ADD FULLTEXT INDEX `idx_user_name` (`user_name`);
Use full-text indexing SQL statement is:
select id,fnum,fdst from dynamic_201606 where match(user_name) against('zhangsan' in boolean mode);
Note: Before you need to create full-text indexes, please contact the DBA to determine whether created. Also of note is the query written statement with the general index difference.