I'm getting pretty slow performance for a pretty simple statement (3-4 seconds):
SELECT col1,col2,col3 FROM table WHERE fname LIKE '%D%' OR fname LIKE '%S%' ORDER BY DATE(bday) DESC LIMIT 0,100
I have index on fname, another on bday and even a joint index on fname & bday. Here's my explain:
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE table ALL NULL NULL NULL NULL 95856 Using where; Using filesort
No index will help you here.
When you're using LIKE '%something%
it's going to have to look at every row and do the string matching.
As stated no index will help. Personally I'd consider full text search overkill for this and add an other column to the table, fill it in on insert update and index that.
Like is for one offs.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.