I have a table with different fields, in particular name (varchar 255), surname (varchar 255), but actually I used them as name (varchar 90) and surname (varchar 70), considering the maxlength limit.
This table has ~620,000 rows and I'm doing a lot of queries like the following one:
SELECT * FROM table WHERE name LIKE "%word1%" AND surname LIKE "%word2%"
I've added FULLTEXT indexes on both field (tried also one index contains both fields), but the performance is slower than queries without any index.
What I missing?
Thanks in advance
Edit: Following your replies, I show you some results.
Case A. Table without any index Query:
SELECT *
FROM `table`
WHERE `name` LIKE '%word1%'
AND `surname` LIKE '%word2%'
executed two times was solved in 0.8870 and 0.8952 sec
Case B. I've added a FULLTEXT index on name and a FULLTEXT index on surname. Query
SELECT *
FROM table
WHERE match(name) AGAINST ('+word1*' in boolean mode)
AND match(surname) AGAINST ('+word2*' in boolean mode)
executed two times was solved in 0.9647 and 1.0380 sec
Note: table has InnoDB engine and unfortunatly MySQL is older than 5.6; I cannot convert easily from InnoDB to MyISAM because of foreign keys.
Other ideas? Thanks again