D
D
Dmitry Skogorev2016-07-08 23:08:40
MySQL
Dmitry Skogorev, 2016-07-08 23:08:40

Is it possible and necessary to make an index on varchar?

Cheer everyone.
I have a table with several fields. there are indexes on fields with type INT - everything is quickly searched for with an exact query
there is a field with type varchar and non-unique data. there are several tens of millions of strings and it became necessary to search like %...% - is it possible to somehow speed up such a search and how to do it?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
entermix, 2016-07-08
@entermix

Index search in MYSQL only works like this: LIKE ...%
www.mysql.ru/docs/man/MySQL_indexes.html

M
Maxim Alekhin, 2016-07-09
@Settler1

From worst to best:
1) innodb + like + index (however, note that '%..%' index is not used, but '...%' is used)
2) change to myisam + full text search index
3) if you need something like a site search, then sphinx

S
Sergey, 2016-07-08
@begemot_sun

If you have myisam and Latin there, then you have a full-text index.
Otherwise only a 3rd party solution like sphinx
like %..% is a very heavy operation and cannot use normal indexes (like b-tree).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question