Home > database >  SQL syntax, why would like '% zhang SAN' index of failure
SQL syntax, why would like '% zhang SAN' index of failure

Time:09-23

SQL syntax, why would like '% zhang SAN' index of failure?

Index indexa fields in table A, A, query using
Select columns from A where A like '% zhang SAN for index failure occurs?
Like grammar like '% zhang SAN' index fails, like 'Joe Smith %' index is normal?
Excuse me why

CodePudding user response:

In MySQL, for example, field index on is actually a b-tree indexes; B-tree indexes can be used like a query, but like the back to a constant string, cannot begin with %
Therefore, select columns from A where A like '% zhang SAN for index failure occurs,

You can see the official document:
https://dev.mysql.com/doc/refman/8.0/en/index-btree-hash.html

CodePudding user response:

Index is sorting, or line up more intuitive,
Like zhang SAN %, actually you are looking for is' zhang SAN XXX ', as long as all the parts' zhang 'at the beginning of the return can, this part is a continuous, don't need a full table scan,
Zhang SAN like '%', actually you are looking for is' XXX zhang SAN, this part is discontinuous in the index, if need to return to the results, only a full table scan,

CodePudding user response:

The most left the principle of the index
  • Related