Current Query:
SELECT * FROM 'fnx_sports' WHERE (Title LIKE '%base%' OR Title LIKE '%ball%')
The above query will take 0.0300 seconds approx.
Faster Query:
SELECT * FROM 'fnx_sports' WHERE (Title LIKE 'base%' OR Title LIKE 'ball%')
The above query will take 0.0010 seconds approx.
The problem:
I need to the results from the first query, as the second (faster) query does not have the wildcard at the start (which allows for indexes to be used).
What options do I have?
One option is to have a separate table which contains all the keywords from the Title field, however this is not appropriate as I am looking to search on a character by character basis, not on a keyword by keyword basis.
For example, the following query should also work:
SELECT * FROM 'fnx_sports' WHERE (Title LIKE 'b%' OR Title LIKE 'b%' OR TitleReversed LIKE 'b%' OR TitleReversed LIKE 'b%')
I'm not sure if this is the most efficient way to do this is. I don't want to modify my table and code structure without confirming the best method. I appreciate any advice!
Note: Cannot use full-text since I have a table which gets quite large and needs constant inserts and selects, therefore I use INNODB instead of MYISAM which is required to use Full Text searches.