LIKE query performance in MySQL

8

Is there any way to increase the performance of a query with LIKE '%string%' in MySQL?

I know that if LIKE is 'string%' , it is faster. The problem is when % is at the beginning of the string. Is there some sort of index we can create to have more performance in this query?

    
asked by anonymous 13.08.2014 / 03:33

2 answers

2

Your answer is no. As noted, if the Full Text search operator MATCH is not used index can not optimize both sides of the query as per Use The Index, Luke! , there is no way to index, or sort values to be optimized with the LIKE operator.

    
19.08.2014 / 01:25
1

Depending on the application an alternative could be made. Imagine a website selling books Let's get clear a table of BOOKS (code, name, author, etc.) A table could be created BOOK_PALAVRA_CHAVE (CODE_LIBER, WORD)

The most important search words would be in this table with the use of index would be an exact search.

The problem is that we users often do not remember the correct spelling, but this does not even LIKE.

    
20.08.2014 / 02:04