My query contains LIKE "%BLABLA"
. Will it optimize my query if I add an index? If yes, will both clustered and unclustered B+Tree indexing improve my query?
Thanks!
My query contains LIKE "%BLABLA"
. Will it optimize my query if I add an index? If yes, will both clustered and unclustered B+Tree indexing improve my query?
Thanks!
LIKE 'abc'
is very similar to = 'abc'
;
LIKE 'abc%'
is a "range", which is likely to be able to us an index;
LIKE '%abc'
cannot use an index - because of the leading wildcard.
If you would like to discuss what could be done for your query, please provide the entire query, plus SHOW CREATE TABLE
.
You can store the reversed data in another field, add an index on that reversed field and query against that reversed field. Instead of using LIKE '%abc'
you will use LIKE 'cba%'
, using the reversed field.