Why doesn't mysql use index for fuzzy search %like

Because the index is an ordered data structure, the B+Tree tree index is arranged in an orderly manner, and the leaf nodes are arranged in order from left to right. If %like is like this, I don't know which one is at the beginning. To perform a full table scan, it is easy to understand

Practice is the truth

Create an index on the field and then query

So you can see it, no index is used

There is a situation where an index will be used, the searched field, if it is an index column, index coverage will occur, and the index will also be used

Also, if you don’t understand, just remember and avoid this situation.

Lord Li

Sister Aihui Aihui

March 4, 2021

Guess you like

Origin blog.csdn.net/guohuiaiwo/article/details/114364252