Sometimes you need to index a long character column, which makes the index larger and slower. One strategy is to emulate a hash index. But sometimes it's not good enough, then?
You can usually index the beginning of several characters, rather than all values, to save space and get good performance. This makes the index less space required, but it also reduces selectivity. Index selectivity is the ratio of non-repeating index values to all rows in the table. A highly selective index is good because it allows MySQL to wave off more rows when looking for matches. The selection rate for a unique index is 1, which is the best value.
If you index blogs and text columns, or long varchar columns, you must define a prefix index because MySQL does not allow indexing of their full culture.
You can calculate for many different prefix lengths in the same query, choosing a good choice. "Linux commune http://www.linuxidc.com"
(with left function, left (city,4))
Add prefix Index
Mysql>alter table Test.test add key (city (7));
The prefix index is a good way to reduce the size and speed of the index, but MySQL cannot use the prefix index in the order by and group by queries, nor do they use the index to overwrite them.
Sometimes a suffix index can be useful, for example, to find all e-mail addresses for a domain name. MySQL does not support reverse indexing, but it can save the inverse string and index its prefix. This index can be maintained with triggers.
MySQL index prefix index and index selectivity