MySQL regexp by index

I have a query with multiple regexp in where where. The columns contained in the where clause are already indexed. But the query doesn't use indexes. Can mysql regexp use indexes? If not, what could be the workaround for this?

+2


a source to share


1 answer


No, regular expression searches cannot use an index. If the thing you're applying the regex to is an index, it might go a little faster, but you're essentially scanning a table.



The only workaround I know of is to use LIKE 'foo%'

instead RLIKE 'foo.*'

if it's your regex. An index on such a column can use LIKE, but not RLIKE

+4


a source







All Articles