Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: binding执行计划跟字符集和排序规则的关系
Version: v4.0.13
The character set and collation of the two query tables are: utf8mb4, utf8mb4_general_ci
character_set_connection: utf8
collation_connection: utf8_general_ci
Create binding:
create global binding for
select …
using
select … force index(idx_created_at)
Login to the client to query:
The execution plan uses the index normally
Checked the dashboard, the execution plan run by the program did not use the index
Check binding information:
show global BINDINGS\G
set session character_set_connection=utf8mb4;
At this time, the client’s execution plan also does not use the binding index
So I thought it might be a problem with the character set and collation
set session collation_connection=utf8mb4_general_ci;
Delete the binding and then recreate the binding
Create binding:
create global binding for
select …
using
select … force index(idx_created_at)
At this time, the binding information
At this time, the program can use the index normally. When we set the connection-related parameters to utf8mb4 and utf8mb4_general_ci, the client can also use the index normally. But after talking with the developers, they said that the connection configuration of the program is also utf8. I can only say that I don’t understand.