SELECT * FROM items WHERE caption LIKE 'name%' AND type = 'private' OR owner LIKE 'name%' type = 'private' ORDER BY uses DESC LIMIT 40;
Possible keys: items_caption,items_owner,items_type
Key: items_uses
(Got these by using the explain command)
It takes about 1.8 seconds to do that query and there are over million records in the table. I don’t know how to make a index for this query and I’ve no control over the source so I can’t modify the query.
Since you’ve got at select *, you can’t really do a covering index, but you could do a pair of composite indexes on (caption,type) and (owner, type).
This should cut down on internal point lookups.
I don’t think you need fulltext search since the value you’re comparing with your LIKE’s do not start with a wildcard (%). Likes that compare with strings not starting with % can use traditional fast b-tree indexes. If you have a % at the start of the LIKE as in ‘%name’ this wouldn’t be the case.
Also, don’t forget the conditions your searching are:
OR
So “ADD FULLTEXT(caption,owner)” won’t help much if the caption clause fails and it tries to lookup by owner and type.