I am doing a query like this on my mysql table:
select * from tblFile WHERE ClientID = 5 AND ProductID = 6 AND FileName LIKE '%4498.tif%';
I have created an index on ClientID, GroupID and FileName.
When I explain the query:
mysql> explain select * from tblFile WHERE ClientID = 5 AND ProductID = 6 AND FileName LIKE '%4498.tif%';
+---------+------+---------------------+---------------------+---------+-------------+--------+------------+
| table | type | possible_keys | key | key_len | ref | rows | Extra |
+---------+------+---------------------+---------------------+---------+-------------+--------+------------+
| tblFile | ref | idx_tblFile_Search1 | idx_tblFile_Search1 | 8 | const,const | 302059 | where used |
+---------+------+---------------------+---------------------+---------+-------------+--------+------------+
It is searching too many rows, which makes my query very slow. How can I create a better index?