Does LIKE support indexing?

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: like支持索引吗

| username: 小于同学

Does like support indexes? Do “%21”, “%123%”, and “342%” all support it?

| username: 啦啦啦啦啦 | Original post link

This should be consistent with MySQL. 342% can be used, and the other two may only be used in cases of covering indexes.

| username: tidb菜鸟一只 | Original post link

Only 342% support, nothing else works.

| username: TiDBer_RjzUpGDL | Original post link

Right blur is acceptable.

| username: 哈喽沃德 | Original post link

Left matching and middle matching use the index, right matching does not use the index.

| username: zhaokede | Original post link

“%21” and “%123%” do not use indexes.

| username: zhanggame1 | Original post link

Currently, only “342%” is supported.

| username: wfxxh | Original post link

Leftmost match

| username: DBAER | Original post link

Leftmost match.

| username: Kongdom | Original post link

Leftmost matching, application layer optimization

| username: TiDBer_rvITcue9 | Original post link

Leftmost match

| username: 随缘天空 | Original post link

The same as the MySQL indexing mechanism.

| username: YuchongXU | Original post link

Supported.

| username: linnana | Original post link

The new version should support it all.

| username: 我是人间不清醒 | Original post link

7.1.3 supports like ‘xxx%’.

| username: TiDBer_LM | Original post link

Yes, it should be consistent with MySQL, 342%.

| username: kelvin | Original post link

Currently, only “342%” is supported.

| username: TiDBer_rvITcue9 | Original post link

Supported.

| username: GreenGuan | Original post link

Supported.

| username: WinterLiu | Original post link

I also always forget this, and after a while, I forget it again :sweat: